错误:
语法错误:文件结束意外
以下是代码
我改变了。
"#!/usr/local/bin/perl"
实际的程序是
#!/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 $_;};
答案 0 :(得分:2)
下面:
`nslookup $host |grep Name: >> $test`;
那时 $test
未定义,所以你要求shell执行nslookup whatever.com |grep Name: >>
。 shell应该将输出重定向到哪里?
如果您将$test
设置为某种内容,例如文件名..甚至是$test = "$host.txt";
,那么它会让您更进一步。
与您的Perl版本无关,虽然use strict;use warnings
能够提供帮助,因为它会发现上述错误。