Why do I get 'use: command not found' when I run my Perl script?

Posted by [email protected] on Stack Overflow See other posts from Stack Overflow or by [email protected]
Published on 2010-03-25T15:57:12Z Indexed on 2010/03/25 17:53 UTC
Read the original article Hit count: 631

Filed under:

I'm new to Perl. And I have used following code from one forum to connect to one of the server. but throwing error messages

[root@Cus]# 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;

But throwing following error messages.

[root@Cus]# ./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');'

© Stack Overflow or respective owner

Related posts about perl