Advertisement

09.22.2006 at 02:13PM PDT, ID: 21999808
[x]
Attachment Details

help writting a perl script to sftp or scp files

Asked by biglarrrr in Perl Programming Language

Tags: perl, sftp, script, scp

Hi,

I need some help with writting a perl script. Here is what I need to do:
1. I need to pull down a bunch of files from an ftp server on a schedulable basis (mainly daily). The file names are all very similar in that they all start with trmasterbuild (e.g. the full file name would be something like trmasterbuild_1234.987654321).

2. The file transfer needs to be secure.

3. Once I pull the files from the ftp server i need to be able to delete the files I just pulled down on the ftp server (e.g. ftp file then delete file on ftp server).

4. Before I delete the file on the ftp server I need to do some kind of verification that the file I just ftped is correct. checksum???

The problem I have is that I've never written a perl script in my life and I can't seem to find any examples. I have found documentation on perl but it doesn't get into much detail on net:sftp or net::scp. All I've found was just plain documentation without examples. That's the other problem I have is that I really don't know if I should use sftp or scp or what. I've written a simple sh that will sftp the files over but it doesn't do what I need most; it doesn't do any verification on the files. Here is the sh I wrote:

#!/bin/sh
HOST='hostname.com'
FILE='*.*'
cd /home/user1/HI0001

sftp $HOST <<END_SCRIPT
cd /user1/dsisap/HI0001
prompt
mget  /home/user1/HI0001/$FILE
quit
END_SCRIPT
exit

Thanks,
biglarrrrStart Free Trial
[+][-]09.24.2006 at 04:35PM PDT, ID: 17588873

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2006 at 08:31AM PDT, ID: 17593146

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.25.2006 at 08:09PM PDT, ID: 17598377

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: perl, sftp, script, scp
Sign Up Now!
Solution Provided By: Tintin
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.26.2006 at 07:32AM PDT, ID: 17601552

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32