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:
Passing arguments to shell script file from PERL

 



tadi18
Novice

Apr 14, 2009, 11:43 AM

Post #1 of 3 (242 views)
Passing arguments to shell script file from PERL Can't Post

Hi, please look at the snippet of my code below:

foreach (@files1)
{

system("sh","/tmp/test.sh $_");

}


Output:
/tmp/test.sh 25
: No such file or directory


It is searching to run the file named "/tmp/test.sh 25" instead of considering "25" as an argument to the script /tmp/test.sh. Please help me on how to achieve this.me


FishMonger
Veteran / Moderator

Apr 14, 2009, 11:51 AM

Post #2 of 3 (239 views)
Re: [tadi18] Passing arguments to shell script file from PERL [In reply to] Can't Post

Try this:

Code
system("sh","/tmp/test.sh", $_);


If your shell script has the correct shebang line, this should work.

Code
system("/tmp/test.sh", $_);



(This post was edited by FishMonger on Apr 14, 2009, 11:52 AM)


tadi18
Novice

Apr 14, 2009, 1:56 PM

Post #3 of 3 (236 views)
Re: [FishMonger] Passing arguments to shell script file from PERL [In reply to] Can't Post

Thanks. It works!

 
 


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

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