iThunder has asked for the wisdom of the Perl Monks concerning the following question:

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; }

Replies are listed 'Best First'.
Re: Trying to do FTP using pseudo-tty
by AppleFritter (Vicar) on May 18, 2014 at 00:05 UTC
Re: Trying to do FTP using pseudo-tty
by AppleFritter (Vicar) on May 18, 2014 at 15:43 UTC
    I see you added those code tags, but the one at the end should be a closing tag: </code>. Your code's still not very readable; I'm sure you'll agree!
      You can even shorten <code> and </code> to <c> and </c>.

      That's just 3 (resp. 4) characters to add.

      Laziness sure is a virtue, but there are limits - escpecially when you expect help for free...

Re: Trying to do FTP using pseudo-tty
by Mr. Muskrat (Canon) on May 20, 2014 at 16:56 UTC
Re: Trying to do FTP using pseudo-tty
by Mr. Muskrat (Canon) on May 20, 2014 at 17:01 UTC

    Can you explain why you need (or think that you need) to do it with a pseudo TTY rather than using Net::FTP?