[Canberra-pm] here document perl script
Kim Holburn
kim at holburn.net
Thu Jun 8 17:29:14 PDT 2006
I want to put a here document fragment of perl in a shell script.
I'm sure I've done something like this before but I can't get it to
work. Anyone got any ideas?
#!/bin/sh
/usr/bin/perl -e -- <<EOP
use Socket;
my \$ip = "$1";
my \$addr = inet_aton(\$ip);
my \$name = gethostbyaddr(\$addr,AF_INET);
my \$ip2 = sprintf "%-20s", "[\$ip]";
if (\$name eq "") { \$name = "not found"; }
my \$begin .= \$ip2 . \$name;
print "\$begin\n";
EOP
$ sh -x fred 123.45.67.8
+ /usr/bin/perl -e --
syntax error at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
--
Kim Holburn
Network Consultant
Ph: +61 2 61258620 M: +61 417820641 F: +61 2 6230 6121
mailto:kim at holburn.net aim://kimholburn
skype://kholburn - PGP Public Key on request
Cacert Root Cert: http://www.cacert.org/cacert.crt
Aust. Spam Act: To stop receiving mail from me: reply and let me know.
Use ISO 8601 dates [YYYY-MM-DD] http://www.saqqara.demon.co.uk/
datefmt.htm
Democracy imposed from without is the severest form of tyranny.
-- Lloyd Biggle, Jr. Analog, Apr 1961
More information about the Canberra-pm
mailing list