2006년 12월 18일 월요일

perl에서 exec와 system의 차이가 있나?

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


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 $!.

system("myprogram --foo $bar") == 0 or die "myprogram failed ($?): $!";
print "myprogram ran successfully.\n";

댓글 없음:

댓글 쓰기