CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Doing ftp using pseudo-tty



May 17, 2014, 4:10 PM

Post #1 of 1 (8570 views)
Doing ftp using pseudo-tty Can't Post


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 ?

use warnings;
use strict;
use Net::Telnet;
use IO::Pty;
use POSIX 'setsid';
use Getopt::Long;

my $host = "";
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;
my $tty = $pty -> slave;
close $pty;
STDIN -> fdopen($tty,"<");
STDOUT -> fdopen($tty,">");
STDERR -> fdopen ($tty, ">");
close $tty;
$| = 1;
exec $cmd,@args;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives