in reply to multi-command sytem call
If a command is terminated by the control operator &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0.What you can do, though, is do something with the return value and then check it later... maybe create a file:
There are other ways to do this, too... depending on whether you actually *wanted* the output of $rpla and $rplb to go to your terminal, you could do this without temp files at all:# clean up if the temp files were already there unlink $_ or die "unlink $_: $!\n" for grep {-e $_} "/tmp/a$$", "/tmp/ +b$$"; system("(perl $rpla && touch /tmp/a$$) & (perl $rplb && touch /tmp/b$$ +)"); $rc = -e "/tmp/a$$" && -e "/tmp/b$$"; # cleanup temp files unlink $_ or die "unlink $_: $!\n" for grep {-e $_} "/tmp/a$$", "/tmp/ +b$$";
Anyway, these all rely on the ability of the shell to fork off not just a single command, but a whole command list expression (and then you chain together the command whose status you want to check with another command that is conditional on the status of the first, and has side-effect that you can verify later).my $output = `(perl $rpla >/dev/null 2>&1 && echo a) & (perl $rplb >/d +ev/null 2>&1 && echo b)`; my $success = $output =~ /a/ && $output =~ /b/;
------------ :Wq Not an editor command: Wq
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: multi-command sytem call
by diotalevi (Canon) on Aug 25, 2004 at 03:55 UTC | |
by etcshadow (Priest) on Aug 25, 2004 at 07:26 UTC | |
|
Re^2: multi-command sytem call
by Elijah (Hermit) on Aug 25, 2004 at 04:20 UTC | |
by belg4mit (Prior) on Aug 25, 2004 at 04:53 UTC | |
by Elijah (Hermit) on Aug 25, 2004 at 15:48 UTC |