1
错误:手指代码 - 不能执行
语法错误:文件意外
末下面是代码
我改变。
"#!/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 $_;};
为了格式化您的代码,请选择它并在编辑框中按CTRL·K。为将来的问题。 – Benoit 2010-10-28 08:56:24
谢谢你...将确保下次 – AAA 2010-10-28 08:58:28
你不能使用比perl 5.003更好的东西吗?它在1996年发布。至于代码中的问题,$ test和$ proto从未初始化(原型被评论),整体事情似乎不稳定。你有没有尝试“perl -w foo.pl hostname”和“perl -d foo.pl hostname”?在调试中,使用“n”执行下一行并“print $ this”或“x @that”进行调查。 – 2010-10-28 09:17:57