On Jul 4, 5:59 pm, knowsuperunkn...@gmail.com (Unknown User) wrote:
> Hi all,
>
> I have written a script that uses ipc::run on an array, like this,
> based on a previous post here:
>
> m...@host101: cat ipc
> #!/usr/bin/perl -w
> use strict;
> use IPC::Run qw/run/;
> my (@hosts,@cmd,$task);
> @hosts = qw/localhost localhost  host101/;
> foreach my $host (@hosts) {
>         $task = sub { qx/ssh $host uptime/ };
>         push(@cmd,"$task",'&');}
>
> run \...@cmd;
>
> But i get the following error when i run it:
>
> m...@host101: ./ipc
> Command 'CODE(0x99c5f10)' not found in /usr/local/bin,
> /usr/local/sbin, /usr/local/bin, /usr/bin, /usr/local/bin, /bin at
> ./ipc line 10
>
> I tried changing the run \...@cmd to run @cmd, but got the same error.
>
> What would be the correct code?
>
> I am running ubuntu 9.10 with IPC::Run version 0.89

Try adding debug to see what's being parsed:

   run debug=>1, @cmd;

Also,  at some point, you'll  need to modify your code reference
a bit:

  my $task = sub { my $out = qx/ssh $host ls/; print $? || $out;  };

Otherwise, you won't see the remote hosts's output or any errors
that occur. See qx operator details in perlop.

--
Charles DeRykus


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to