<?xml version="1.0" encoding="windows-1252"?>
<node id="304388" title="Poor mans Netcat" created="2003-11-04 07:17:30" updated="2005-08-14 04:32:40">
<type id="121">
perlcraft</type>
<author id="5348">
Corion</author>
<data>
<field name="doctext">
#!/usr/bin/perl -w
# As our unix printer setup is weird and I sometimes want to
# print to networked (HP) printers, I needed something like
# netcat. I was unsatisfied with &lt;tt&gt;telnet&lt;/tt&gt;, as it did
# output stuff I didn't want, and I didn't want to add the
# redirection to /dev/null. Perl to the rescue:

use strict;
use IO::Socket;

select IO::Socket::INET-&gt;new(PeerAddr =&gt; shift, PeerPort =&gt; (shift || 23));
print
  for &lt;&gt;;

__END__
# or, as a oneliner:
perl -MIO::Socket -pe 'BEGIN{select IO::Socket::INET-&gt;new(PeerAddr=&gt;shift,PeerPort =&gt;(shift||23))}'
</field>
</data>
</node>
