Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::SCP sample code

Status
Not open for further replies.

topmac

Programmer
Nov 7, 2005
17
US
Hi all,
I am trying to write an automated process that hits a Linux server and SCP's files over to local machine.
From CPAN I got the following code.... but it doesnt work for me. There is no error message either...!!

Could you please give me a sample working code that has error handling..!!
Code:
# from CPAN
$scp = Net::SCP->new("204.139.0.224");
$scp->login("udays");
#$scp->cwd("/dir");
$scp->size("tax.pl");
$scp->get("tax.pl");
#$scp->quit;

I installed Net::SCP using PPM.

thanks in advance,
_Uday
 
Hi,

From the example in the documentation I suggest the following approach to error handling;
Code:
# from CPAN
$scp = Net::SCP->new("204.139.0.224")
[tab] or die $scp->{errstr};
$scp->login("udays")
[tab] or die $scp->{errstr};
$scp->cwd("/dir")
[tab] or die $scp->{errstr};
$scp->size("tax.pl")
[tab] or die $scp->{errstr};
$scp->get("tax.pl")
[tab] or die $scp->{errstr};
$scp->quit
[tab] or die $scp->{errstr};


Mike

I am not inscrutable. [orientalbow]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884

 
thanks for your reply Mike...

don't we provide password to login....!!

Also please post if you have any URL's with examples and tutorials..!!

I really appreciate your help,
_Uday
 
Looks like the login process is by RSA keys...!
does anyone know if there is a good and simple tutorial to do this.. on a windows machine.

any comments are greatly appreciated,

thanks a lot,
_Uday
 
The documentation looks quite good to me, what are you having trouble with?

Mike

I am not inscrutable. [orientalbow]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884

 
I have activestate perl on a windows machine.
1 - So how do I create rsa keys...!!
2 - where do I run sys-keygen and other commands....
3 - Where should these keys be saved for my perl process to see..

I am just a newbie...!! so I have whole bunch of other questions..!! but the ones above are main.

_Uday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top