我是Perl新手。我已經使用以下來自一個論壇的代碼連接到一臺服務器。但拋出錯誤信息當我運行我的Perl腳本時,爲什麼會得到'use:command not found'?
[[email protected]]# cat tt.pl
#!/usr/bin/perl
use Net::Telnet;
$telnet = new Net::Telnet (Timeout=>2, Errmode=>'die');
$telnet->open('10.0.0.28');
$telnet->waitfor('/login:/');
$telnet->print('administrator');
$telnet->waitfor('/Password:/');
$telnet->print('test');
$telnet->waitfor('/switch8-12>/');
$telnet->print('whoamI');
$output=$telnet->waitfor('/switch8-12>/');
print $output;
但拋出以下錯誤信息。
[[email protected]]# ./tt.pl
./tt.pl: line 3: use: command not found
./tt.pl: line 4: syntax error near unexpected token `('
./tt.pl: line 4: `$telnet = new Net::Telnet (Timeout=>2, Errmode=>'die');'
您正在使用哪個外殼? – 2010-03-25 16:10:20
這些是shell錯誤,而不是Perl錯誤。你能告訴我們你正在使用哪種設置嗎? – 2010-03-25 16:33:39
奇怪的是,錯誤消息行號是從你的代碼行關閉的。 – toolic 2010-03-25 16:36:22