Solved

Using sftp in perl without using NET::SFTP

Posted on 2008-06-18
6
1,369 Views
Last Modified: 2011-09-20
Hello,

Can anyone please help explain how to use sftp in perl without using NET::SFTP. I think it will be possible just by using binary commands in program. For eg. using
sft username\@hostname.
If I want to use this from program where should I put password? If anyone put some sample lines that would be a great help. Urgent replies would be highly appreciated.

Thank you as always!
0
Comment
Question by:Andys1
6 Comments
 
LVL 13

Assisted Solution

by:MicheleMarcon
MicheleMarcon earned 100 total points
ID: 21819554
0
 

Author Comment

by:Andys1
ID: 21819741
Hello I can not check this link from my office as it is filtered. It would be a great help if you could paste the contents or otherwise I will check it at home. THank you
0
 
LVL 48

Accepted Solution

by:
Tintin earned 200 total points
ID: 21819931
That link doesn't really contain the information you are after.

Firstly, why don't you want to use Net::SFTP?

Here's an example of feeding responses to sftp
open SFTP, "/usr/bin/sftp user@host|" or die "Can not run sftp $!\n";
print SFTP "some command\n";
print SFTP "some other command\n";
print SFTP "exit\n";
close SFTP;

Open in new window

0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:Andys1
ID: 21819984
Thanks Tintin, Acutally I am using perl5.0024 and I copied NET::SFTP and refered the directory using use lib (path) but it threw some exceptions. In my company if I want to install any package then I have to go through various steps and very time consuming so I decided to use SFTP.

Just wondering where to specify the password in above code? I want to schedule this program from cron jobs.
0
 
LVL 16

Assisted Solution

by:xDamox
xDamox earned 200 total points
ID: 21820722
Hello,

I would recommend you use public key authentication with SFTP this will make your program
much simpler to write.

0
 
LVL 48

Expert Comment

by:Tintin
ID: 21820989
Diito regarding ssh keys.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question