Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Can I use perl to run a telnet or ftp session?

by faq_monk (Initiate)
on Oct 08, 1999 at 00:29 UTC ( #736=perlfaq nodetype: print w/replies, xml ) Need Help??

Current Perl documentation can be found at

Here is our local, out-dated (pre-5.6) version:

Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from CPAN). will also help for emulating the telnet protocol, but Net::Telnet is quite probably easier to use..

If all you want to do is pretend to be telnet but don't need the initial telnet handshaking, then the standard dual-process approach will suffice:

    use IO::Socket;             # new in 5.004
    $handle = IO::Socket::INET->new('')
            || die "can't connect to port 80 on $!";
    if (fork()) {               # XXX: undef means failure
        print while <STDIN>;    # everything from stdin to socket
    } else {
        print while <$handle>;  # everything from socket to stdout
    close $handle;

Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2016-10-21 18:14 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.