CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
find with in a perl script behaves stragely

 



ianilkumar
Novice

Nov 16, 2012, 9:57 AM

Post #1 of 4 (1163 views)
find with in a perl script behaves stragely Can't Post

Trying to use the output of a find command in a perl script:

my @pin_conf_files = `find . -name "create*.opc" -exec grep -l PIN_FLD_PASSWD {} \;`;
foreach my $file(@pin_conf_files)
{
chomp($file);
open (FILE,"<$file");
while (<FILE>)
{
chomp;
if ($_ =~ m/(\d\s+PIN_FLD_PASSWD_CLEAR\s+/[0/]\s+)(.*)$/g)
print $file;

}
close FILE;
}
#}


But it returns an error as
find: missing argument to `-exec'

It works fine on the command line.


FishMonger
Veteran / Moderator

Nov 16, 2012, 10:30 AM

Post #2 of 4 (1160 views)
Re: [ianilkumar] find with in a perl script behaves stragely [In reply to] Can't Post

Try adding single quotes around the braces.


Code
`find . -name "create*.opc" -exec grep -l PIN_FLD_PASSWD '{}' \;`



ianilkumar
Novice

Nov 16, 2012, 4:03 PM

Post #3 of 4 (1149 views)
Re: [FishMonger] find with in a perl script behaves stragely [In reply to] Can't Post

No luck.


Laurent_R
Veteran / Moderator

Nov 17, 2012, 12:29 AM

Post #4 of 4 (1143 views)
Re: [ianilkumar] find with in a perl script behaves stragely [In reply to] Can't Post

The error message is from the shell, not from Perl. The command line you issue in your script fails with the same message when I issue it at the bash prompt. It looks like you have something wrong in your "find ... -exec" syntax.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives