|
|
|
|
![]() ![]() |
Aug 17 2005, 08:07 AM
Post
#1
|
|
|
Premium Member Group: Members Posts: 493 Joined: 15-August 05 Member No.: 7,873 |
I am writing a script to add submit/add projects to a queue. I don't need a returned result other than it worked or failed. The script will execute a commandline like thisL
'program -b $filename -s $start -e $end -a' all I need is for that command to be send and if it suceeds return a simple "This worked" or "This failed: here is why ___________". I am just trying to remember the difference between exec and system() for this task. I've read through the documentation and am still a little confused. It's the first time I've really used PERL in at least four years. This post has been edited by microscopic^earthling: Aug 17 2005, 08:52 AM |
|
|
|
Aug 17 2005, 09:50 AM
Post
#2
|
|
|
Way Out Of Control - You need a life :) Group: [MODERATOR] Posts: 1,980 Joined: 16-August 05 Member No.: 7,896 |
Read your doc carefully.
On unix or Linux shell scripts, "exec" means "execute what I tell you and exit immediately after that". This means that, in Unix, all the lines after the exec instruction are ignored... |
|
|
|
Nov 3 2005, 05:27 PM
Post
#3
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 9 Joined: 3-November 05 Member No.: 9,422 |
Use backticks to capture output.
CODE $output = `program optional_arguments_jere`; Please note that those are backticks(on QWERTY it's right below the Escape key). Regards, Digital Technic. |
|
|
|
Nov 17 2005, 11:07 AM
Post
#4
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 4 Joined: 17-November 05 Member No.: 9,668 |
Use the system() function to execute a program without saving the program's output. The return value of the system() function is the program's exit status or you could check the special $? variable which will have it as well.
The exit value 0 means the program exited successfully and anything else probably means there was a problem. If there was an error then it will be stored in $!. CODE system("myprogram --foo $bar") == 0 or die "myprogram failed ($?): $!";
print "myprogram ran successfully.\n"; |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 30th August 2008 - 02:33 PM |