Perl Net::SSH doesn't receive prompts -


i writing script communicate remote server. understand how send basic shell command such "ls" or "find / |grep foo". executing interactive application @ other end.

if call $ssh->shell, prompt remote server know ssh receiving prompt. can't because script blocked in shell.

i installed 2 handlers. if use script connect basic ssh host, , execute shell command, response delivered handlers, know ok. expected prompt application executing sent these isn't.

#!/usr/bin/perl -w use strict;     use net::ssh::perl;      $host = 'rt.olsendata.com'; $user = 'rtdemo'; $pass = 'rtdemo';     %params = ('debug' => 1,'protocol' => 2); $ssh = net::ssh::perl->new($host, %params);  $ssh->register_handler("stderr", sub{              ($ssh, $packet) = @_;             receiveerrors($packet);         }); $ssh->register_handler("stdout", sub{              ($ssh, $packet) = @_;             receivedata($packet);         }); ($output, $errors, $exit) = $ssh->login($user, $pass); 

at point need respond prompt sending "1". interpreted remote host shell command, not response prompt. returns error "h: 1: no such file or directory".

if want try can use demo ssh account @ top of code. publicly available.

edit: realise expect solves issue, not find equivalent register_handler() in expect. right in this?

i use expect automate ssh/sftp sessions.


net::ssh::perl provides shell() method "interactive" sessions. otherwise, one, brethren, assumes you're executing single command on remote server.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -