Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Multiple commands with one system call

by graff (Chancellor)
on Oct 13, 2011 at 02:24 UTC ( [id://931124]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Multiple commands with one system call
in thread Multiple commands with one system call

Hey yourself!

Is there something that makes you unable to paste the actual text of the error message into your post? What does "It" refer to? What does "the preceding line" refer to? What exactly did you try, and what exactly was the full error message? Were you using the code as I posted it, or did you try something "based on" my post? What OS are you using?

If you could give more explicit information about the problem(s) you're having, you might get some useful help.

  • Comment on Re^3: Multiple commands with one system call

Replies are listed 'Best First'.
Re^4: Multiple commands with one system call
by renzosilv (Novice) on Oct 13, 2011 at 14:10 UTC

    The error is not very descriptive but here it is

    Too many arguments for open at /home/vpoint/testing.pl line 10, near " +'/bin/bash' ) " Execution of /home/vpoint/testing.pl aborted due to compilation errors +.

    I was trying to use the code exactly as you posted it. The only thing I removed was use warnings. The OS I am using is

     SunOS ferb 5.8 Generic_117350-21 sun4u sparc SUNW,Ultra-80

    This is the perl version in case it helps.

     perl, version 5.005_03 built for sun4-solari
      perl, version 5.005_03 built for sun4-solari

      That explains it. Your ancient SunOS system is using an ancient Perl release. The code I posted requires Perl 5.8 or later, due to its use of the "3-argument" form of the open call, which wasn't available in perl 5.5 (which is what you have in this case). Sorry, I just assumed that no one would still be using such an old version of Perl.

      To fix that, use the "2-argument" form for the open call -- like this:

      #!/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";
      That approach will also work with more recent versions of perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://931124]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-18 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found