Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl command from within a script

Status
Not open for further replies.

whughey

Technical User
May 17, 2001
4
US
I have a one line perl command that works perfect from the command line (linux), but when trying to use it in another script with the system command, I get:
sh: syntax error near unexpected token `f)'
sh: -c: line 1: `perl -p -i -e 's/template.com/test.com/g;' 0 10 6 4 3 2 1 0find /home/test/* -type f)'

The command:
perl -p -i -e "s/template.com/test.com/g;" $(find /home/test/* -type f)

I tried the following inside my script:
system ("perl -p -i -e 's/template\.com/test\.com/g;' $(find /home/test/* -type f)");
Any suggestion?
 
I believe it's due to the [tt]$[/tt] symbol being interpreted as part of a perl variable. Try escaping this symbol as [tt]\$[/tt]. Alternatively, use the [tt]File::Find[/tt] package - see faq219-969 for an example of its use.

Cheers Neil :cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top