On May 17, 7:09 pm, Ben Morrow <
b...@morrow.me.uk> wrote:
> Quoth Nene <
rodbas...@gmail.com>:
>
> > My variable $main::newvar , which holds a very long command will not
> > print to screen after '$ssh->run_ssh() or die "SSH process couldn't
> > start: $!";'
>
> > #!!/usr/bin/perl -w
Correct, It's a typo, I just copied and pasted the code that is giving
me trouble.
>
> That's not what a ~! line looks like. Also, you want
>
> use warnings;
Ok, thanks.
>
> rather than -w.
>
> > use strict;
It's at the top of the script.
>
> > my $ssh = Net::SSH::Expect->new (
> > host => "xxxxxxx",
> > password=> 'xxxxxx',
> > user => 'xxxxxx',
> > raw_pty => 1
> > );
>
> > print "$main::newvar\n", br; #### It prints here...
>
> Where does 'br' come from? Is this a CGI script? Please post complete
> programs.
It is a CGI script (use CGI is at the top of the page)
>
> > # now start the ssh process
> > $ssh->run_ssh() or die "SSH process couldn't start: $!";
The variable doesn't print after the run_ssh command too.
>
> > $ssh->waitfor('\[xxxxxxx\@a_box:Standby\].* \#', 3) or die "prompt not
> > found after 3 second";
The 'waitfor' is not an issue here, tested.
>
> [I *do* hope that # doesn't indicate you're logging in as root with a
> password kept in a CGI script...]
I'm not.
>
> > print "$main::newvar\n", br; It DOES NOT print here.....
>
> If this *is* a CGI script, then probably what happened is that the
> ->waitfor failed, the script died, and the error is in a server error
> log somewhere where you haven't found it. You may find CGI::Carp
> helpful, at least during development.
It's not the waitfor command, it doesn't produce an error, it is
authenticating and I'm able to run system commands.
>
> Ben