In the above example you will actually see the printed statement appear on the screen following an error message saying that the command "lt" does not exist. When the command or target program does not exist, or the call fails for any other reson is the only time you will get a "return" from exec().#!/usr/bin/perl -w use strict; my $results = exec("lt", "-al", "."); print <<END; ########################### \$results \= $results ########################### END
Now this code will perform the list (ls) command on a *nix system feeding it "-al" as command line arguiments and "." (current dir) as the target to list. That is all the will appear on the screen and the following print statement will never be executed because the exec() function was successfull and overwrote this current process.#!/usr/bin/perl -w use strict; my $results = exec("ls", "-al", "."); print <<END; ########################### \$results \= $results ########################### END
Sorry for any confusion.
In reply to Re^4: multi-command sytem call
by Elijah
in thread multi-command sytem call
by water
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |