in reply to Multiple commands with one system call
#!/usr/bin/perl use strict; use warnings; my @cmd_list = ( 'echo 1', 'echo 2', 'echo 3', 'echo 4' ); $|++; # turn off buffering my $shpid = open( my $sh, '|-', '/bin/bash' ) or die "Can't open a shell process: $!\n"; for my $cmd ( @cmd_list ) { print $sh "$cmd\n"; } print $sh "exit\n"; close $sh; waitpid( $shpid, 0 ); print "Shell's all done. Moving right along...\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Multiple commands with one system call
by renzosilv (Novice) on Oct 12, 2011 at 16:08 UTC | |
by graff (Chancellor) on Oct 13, 2011 at 02:24 UTC | |
by renzosilv (Novice) on Oct 13, 2011 at 14:10 UTC | |
by graff (Chancellor) on Oct 13, 2011 at 19:28 UTC |