#!/usr/bin/perl # perl-ish script to subst missing 'nc' - connect mode only # hacked by Wejn (wejn(at)box(dot)cz), from perl cookbook example # # PS: I hate perl, I really do. use IO::Socket; $remote_host = shift; $remote_port = shift; if ($remote_host eq '' || $remote_port eq '') { print "Usage: perlnc \n"; exit 1; } $socket = IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto => "tcp", Type => SOCK_STREAM, Timeout => 5) or die "Couldn't connect to $remote_host:$remote_port : $@\n"; # ... do something with the socket print $socket $data while $data = ; # and terminate the connection when we're done close($socket); exit 0;