Operating System - HP-UX
1753815 Members
8077 Online
108805 Solutions
New Discussion юеВ

Re: Perl - Not Getting Output

 
Virat
Occasional Contributor

Perl - Not Getting Output

Hi All,
Following Code is executes well without any issue...but doesn't do its job. I have checked the logs as well but it doesn't perform its task. Will be very helpful if you can identify the issue with it...

fyi - I am trying to take configuration backup of a switch to a ftp machine.
###############################################
use Net::Telnet;
my $filename = "dump.log";
my $file = "input.log";
$telnet = new Net::Telnet ( Timeout=>5,Errmode=>'die',Prompt => '/.*>/',Dump_Log
=> $filename,Input_log => $file);
$telnet->open('10.25.4.11');
$telnet->login('admin','password');
$telnet->print('configupload');
$telnet->waitfor('/.*: $/i');
$telnet->print('ftp');
$telnet->waitfor('/.*: $/i');
$telnet->print('abemr012');#hostname
$telnet->waitfor('/.*: $/');
$telnet->print('10.18.15.53');#host ip addr
$telnet->waitfor('/.*: $/');
$telnet->print('admin');#ftp uid
$telnet->waitfor('/.*: $/');
$telnet->print('temp.txt');#file name for bkp
$telnet->waitfor('/.*: $/');
$telnet->print('password');#admin uid passwd
print $telnet->waitfor('/.*/');#prints 1, and doesn't perform its task as well.

Any help is appreciated!
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: Perl - Not Getting Output

Hi:

It would seem that if an FTP is the objective, using 'Net::FTP' would be the desirable approach.

That said, the FTP dialog that you are trying to establish doesn't look valid. You issue a bare "ftp" command; wait for a response; and then supply a hostname without preceding it with the 'open' command. This is going to fail. You do similar things as your dialog proceeds.

Regards!

...JRF...
Virat
Occasional Contributor

Re: Perl - Not Getting Output

Hi,
Actually I am connecting to switch via perl script from my local pc. Now switch itself provides functionality to takes its configuration backup to a ftp server. We need not have to open saperate connection from switch to ftp server. Hence I think we need not have to use ::FTP. Any suggestions?
James R. Ferguson
Acclaimed Contributor

Re: Perl - Not Getting Output

Hi (again):

Regardless of from where you want to fetch your file, the simplest method (IMO) is to use Perl's Net::FTP. This will be a simple, direct way to achieve your goal.

Regards!

...JRF...