[cactiuser@tat scripts]$ cat test-n2.pl #!/usr/bin/perl use Net::Telnet; use constant HOST => '192.168.9.2'; use constant USER => 'shineyang'; use constant PASS => 'secret'; my $khprompt = '/\[telepath\@SMSCN2\]\s/'; my $term = 'vt100'; &getdata; sub getdata #Get the data from NG SMSC series { open (result, "> /home/cactiuser/TWM_N4/log/result-hourly.txt"); my $t= Net::Telnet->new(HOST => '192.168.9.2', Dump_Log => 'test-dump.txt', Input_log => 'test-input.txt', PORT => 23, ERRMODE => "return", Prompt => $khprompt, Timeout => 10); print "Connected-192.168.9.2\n"; unless ( defined $t ) { print "problem connecting\n"; exit; } #$t->print ('vt100') or die "cannot go next" ; $t->login( Name => USER, Password => PASS, Timeout => 20, ) or die "Cannot login "; $t->prompt('/TERM\s/=\s/(hp/)\s/'); $t->cmd( String => $term, Dump_Log => 'cmd-dump.txt', Input_log => 'cmd-input.txt', ); $t->cmd('ls'); $t->cmd('exit'); $t->close; close(result); }