in reply to Net::SSH::Perl (Use of uninitialized value $stdout)
Unless I am not fully awake yet, it appears that you are using backtics "`" as opposed to single quotes "'" to assign a value:
The end effect of this is that you are telling perl to execute the command inside the backtics, and place any output from STDOUT in the variable $cmd. I presume that what you want is to assign the string consisting of 'ls -l' to $cmd which is then executed on the remote host.my $cmd = `ls -l`;
EDIT: Simplistic demo of above:
$ cat backtictest.pl #!/usr/bin/perl use strict; use warnings; my $cmd_sq = 'ls -l'; print "Using single quotes: $cmd_sq\n\n"; my $cmd_bt = `ls -l`; print "Using backtics: $cmd_bt\n"; exit; __END__ Output: Macintosh-45:stuff user$ ./backtictest.pl Using single quotes: ls -l Using backtics: -rw-r--r-- 1 user group 260 May 6 17:58 Class1.pm -rw-r--r-- 1 user group 260 May 6 17:58 Class2.pm -rw-r--r-- 1 user group 331 May 6 17:58 MyExceptions.pm -rwx------ 1 user group 182 May 21 07:38 backtictest.pl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Net::SSH::Perl (Use of uninitialized value $stdout)
by thanos1983 (Parson) on May 21, 2014 at 14:55 UTC |