tags:

views:

46

answers:

1

Error:

Syntax error: end of file unexpected

Below is the Code

I changed.

"#!/usr/local/bin/perl"

The actual program is

#!/local/perl5/bin/perl5.003

use Socket;

$sockaddr = 'S n a4 x8';

$host = $ARGV[0];
$them = $host;
$port = 79;
print "Finger $host: \n";
$hostname = ``;
`nslookup $host |grep Name:  >> $test`;
print $test;
#($name, $aliases, $proto) = getprotobyname('tcp');

($name, $aliases, $port) = getservbyname($port, 'tcp') unless $port =~ /^\d+$/;
($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname);
$n1 = $name;
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);

$this = pack($sockaddr, &AF_INET, 0, $thisaddr);
$that = pack($sockaddr, &AF_INET, $port, $thataddr);

socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";

bind(S, $this) || die "bind: $!";
connect(S, $that);

select(S); $| = 1; select(stdout);

print S "\n\n";

while (<S>) {print $_;};
+2  A: 

Here:

`nslookup $host |grep Name:  >> $test`;

$test is undefined at that point, so you're asking the shell to execute nslookup whatever.com |grep Name: >>. Where is the shell supposed to redirect the output to?

If you set $test to be something, like a filename.. or even $test = "$host.txt"; it will get you further.

Nothing to do with your Perl version, although being able to use strict;use warnings does help, as it would've caught the above error.

mfontani