Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Syntactic Confectionery Delight
 
PerlMonks  

Poor mans Netcat

by Corion (Pope)
on Nov 04, 2003 at 12:17 UTC ( #304388=perlcraft: print w/ replies, xml ) Need Help??

   1: #!/usr/bin/perl -w
   2: # As our unix printer setup is weird and I sometimes want to
   3: # print to networked (HP) printers, I needed something like
   4: # netcat. I was unsatisfied with <tt>telnet</tt>, as it did
   5: # output stuff I didn't want, and I didn't want to add the
   6: # redirection to /dev/null. Perl to the rescue:
   7: 
   8: use strict;
   9: use IO::Socket;
  10: 
  11: select IO::Socket::INET->new(PeerAddr => shift, PeerPort => (shift || 23));
  12: print
  13:   for <>;
  14: 
  15: __END__
  16: # or, as a oneliner:
  17: perl -MIO::Socket -pe 'BEGIN{select IO::Socket::INET->new(PeerAddr=>shift,PeerPort =>(shift||23))}'

Comment on Poor mans Netcat
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlcraft [id://304388]
Approved by barrd
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2013-05-18 18:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (394 votes), past polls