Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Net::OpenSSH Problem

by salva (Abbot)
on Sep 11, 2013 at 08:09 UTC ( #1053425=note: print w/replies, xml ) Need Help??


in reply to Net::OpenSSH Problem

system keeps waiting for the remote command (in your case !bash) to exit before returning control to your program and probably !bash is waiting for you to write some commands at the terminal.

Read the first entry on the module FAQ for a description of the issue you are facing.

Is there any online documentation for that device? maybe there is some way to run unix commands without going through the custom shell.

Replies are listed 'Best First'.
Re^2: Net::OpenSSH Problem
by kburns1969 (Novice) on Sep 11, 2013 at 16:28 UTC

    Ok I am a bit closer. I know that !bash ran correctly in the remote session because while it was sitting there I typed the pwd and received the correct result. I guess now I am confused as to why the program is waiting on me to interact with it instead of continuing to run the other commands. Current code below

    -bash-4.1$ ./test1.pl # open_ex: ['ssh','-O','check','-T','-S','/home/kburns/.libnet-openssh +-perl/kburns-10.10.10.-20023-380016','-l','kburns','10.10.10.1','--'] # _waitpid(20025) => pid: 20025, rc: # open_ex: ['ssh','-S','/home/kburns/.libnet-openssh-perl/kburns-10.10 +.10.-20023-380016','-l','kburns','10.10.10.1','--','!bash']

    I typed pwd and it worked so I know !bash ran correctly on the remote end.

    pwd
    /home/kburns
    my $ssh = Net::OpenSSH->new($host, user => $USERNAME, password => $PAS +SWORD, str ict_mode => 0); $ssh->error and die "Couldn't establish SSH connection: " . $ssh->erro +r; $ssh->system('!bash') or die "remote command failed: " . $ssh->error; print "!bash done\n"; $ssh->system('pwd') or die "remote command failed: " . $ssh->error; print "pwd done\n"; # never gets here. it hangs
      what happens when you run the following code?
      my $ssh = Net::OpenSSH->new($host, user => $USERNAME, password => $PASSWORD, strict_mode => 0); $ssh->error and die "Couldn't establish SSH connection: " . $ssh->erro +r; $ssh->system('!pwd') or die "remote command failed: " . $ssh->error; print "pwd done\n";
        It runs fine outputting my current home dir. Def a problem of it not giving back control to the script or something ??
        $ssh->error and die "Couldn't establish SSH connection: " . $ssh->erro +r; $ssh->system('!bash') or die "remote command failed: " . $ssh->error; # remote end will look like this after !bash # bp>!bash # [kburns@ssl01-d:Active] ~ # print "will never print this line\n"; $ssh->system('pwd') or die "remote command failed: " . $ssh->error;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053425]
help
Chatterbox?
[Corion]: AltSpace VR is amazingly good - highly polished and with some of the games you get for free what you'd pay EUR 20 or EUR 40 otherwise
[Corion]: But maybe it's also due to that I play with friends, which makes a game more enjoyable anyway ;)
[Corion]: Oh - I released a new version of some module, thanks to a pull request. But I don't consider "update Makefile.PL" and "update author tests" as "writing code" ;-D
[marto]: sounds fun, the opposite of my weekend :P
[Corion]: marto: You wrote Perl? Or did you have to work (and wrote Perl)?

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2017-08-21 09:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (319 votes). Check out past polls.

    Notices?