Hi,
I'm wondering if someone can help me with an issue I'm having when using OpenSSH. I am setting up a connection and executing a command using capture. The command runs successfully and I get the output. However, the page does not finish loading (its status remains "Transferring data from 192.168.0.1"). Consequently, javascript code which should run when the page completes loading does not run.
I have tried various options and combinations but have not managed to solve this. Can I force closing the connection?
This is the code I'm using:
my ($def_in, $def_out);
open $def_in, '<', '/dev/null' or die "unable to open /dev/null";
open $def_out, '>', '/dev/null' or die "unable to open /dev/null";
my $host = '192.168.0.1';
my %opts = ( user => 'root',
batch_mode => 1,
key_path => '~/.ssh/id_rsa',
ssh_cmd => '/usr/bin/ssh',
default_stdin_fh => $def_in,
default_stdout_fh => $def_out,
kill_ssh_on_timeout => 1,
timeout => 5
);
my $ssh = Net::OpenSSH->new( $host, %opts );
$ssh->error and die "Unable to connect to server. ".$ssh->error;
my $text = $ssh->capture({stderr_to_stdout => 1, timeout=>1, stdin
+_data => "cat /myfile.txt;exit\n"});
#$ssh->capture({stdin_data => "exit\n"});
undef $ssh;
Many thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.