Hello,
I am trying to do FTP with pseudo-tty using below code.
In packet captures, i can see that code is sending the username root in request command user but it doesnt send password (i.e. no request argument sent in Request command: PASS). Any suggestions ?
#!/usr/bin/perl
use warnings;
use strict;
use Net::Telnet;
use IO::Pty;
use POSIX 'setsid';
use Getopt::Long;
my $host = "192.168.1.121";
my $user = "root";
my $ssh = do_cmd('ftp',$host);
my $shell = Net::Telnet -> new(Fhopen => $ssh);
$shell -> binmode(1);
$shell -> cmd(String => 'root', Prompt => '/[a-z]/');
$shell -> cmd(String => 'password', Prompt => '/[a-z]/');
my @lines = $shell->cmd(String => 'ls', Prompt => '/[a-z]/');
print @lines;
print "\n";
sub do_cmd{
my ($cmd,@args) = @_;
my $pty = IO::Pty -> new;
defined (my $child = fork);
return $pty if $child;
setsid();
my $tty = $pty -> slave;
close $pty;
STDIN -> fdopen($tty,"<");
STDOUT -> fdopen($tty,">");
STDERR -> fdopen ($tty, ">");
close $tty;
$| = 1;
exec $cmd,@args;
}
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.