sftp shell that will validate files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sftp shell that will validate files
# 1  
Old 09-22-2006
sftp shell that will validate files

Hi. I've written a shell that will sftp about 5,000 to 10,000 files a day (they are small 200 byte files). Where I'm stuck at is that I need to not only copy those files from the ftp server, I also need to delete the files on the ftp server after they have been ftped BUT before they've been validated. What I mean is, before I delete them from the ftp server, I need to somehow validate/verify that the files got transfered correctly - checksum???. If a file got transfered correctly then I can delete it from the ftp server and move on to the next. If a file didn't get transfered correctly I need to log it with the full file name, put that "bad" file in a new directory and then continue on to the next file. Here is my shell so far:

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

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

Thanks,
biglarrrr
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Validate compressed files

Hi All, I have zip file that needs to be validated and checked for 5 times with sleep of 60 seconds. Some thing like below #!/bin/bash counter=1 while do curl -i -k -X GET `strings tmp.txt |grep Location| cut -f2 -d" "` -H "Authorization: Token $TOKEN" -o $zip_file ## this is... (6 Replies)
Discussion started by: Master_Mind
6 Replies

2. Shell Programming and Scripting

Shell Script to validate the access for Servers

Hi Experts, Please advise to Write a Shell script, To check , whether the user has access to UNIX PRODUCTION server or not? If no, then need to provide the access to UNIX PRODUCTION server and then need to provide access to print only few FILES. After connecting to ther server, again... (5 Replies)
Discussion started by: vasuvv
5 Replies

3. HP-UX

Shell script to sftp files to file server.

Hi, I am looking for a shell script to sftp to a file server and copy all the files from a directory after the script is run. The server name should be a user input parameter and of-course the username/password as well. Rest all should be handled by the script. I tried with below snippet:-... (2 Replies)
Discussion started by: happysingh
2 Replies

4. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

5. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

6. Shell Programming and Scripting

Validate before moving files.

File Format dataline1,12,,,,; dataline2,24,,,; dataline3,12,,,,; dataline4,24,,,; COUNT=0004; Hi, I have source(/home/rgupta) and destination folders /home/rgupta/arch and /home/rgupta/err. Source folders has many files. I want to move the files from source to destination with some... (1 Reply)
Discussion started by: ravigupta2u
1 Replies

7. Shell Programming and Scripting

How to validate files after FTP

Hi, I have to write a script and the requirment where using ftp i need to get 8 files from a remote box to local. I know how how to ftp and do get. However i want do a validation after get. After geting for 8 files, i want to compare the size of the 8 files when it was in remote box with size... (6 Replies)
Discussion started by: tarakant
6 Replies

8. Shell Programming and Scripting

shell script to get sftp files

did anyone knows a script to get a latest file in a folder,,i try to get the newest file at a folder via sftp and i want to make a crontab to do this once a day,,can someone give me the script to get the latest file?? (5 Replies)
Discussion started by: Cellscript
5 Replies

9. Shell Programming and Scripting

sftp validate files before removal

I have a shell, which locks calls an expect script that connects to an sftp and downloads all files. I need it to then check each file in my directory and compare the sizes. If the file name and file size match, then delete the file on the server. Is this possible? :confused: (2 Replies)
Discussion started by: tariqjamal
2 Replies

10. Shell Programming and Scripting

korn shell + sftp + list files

Hello!!! I need a korn shell script in AIX that inside sftp environment, changes a remote directory, lists the files inside it, and stores in an array. I got it working before make a sftp, but after.. I can't.. The way it is, it lists the files in local path... so.. not what I want, but... (1 Reply)
Discussion started by: alienET
1 Replies
Login or Register to Ask a Question
sftp-server(1M) 					  System Administration Commands					   sftp-server(1M)

NAME
sftp-server - SFTP server subsystem SYNOPSIS
/usr/lib/ssh/sftp-server DESCRIPTION
sftp-server implements the server side of the SSH File Transfer Protocol as defined in the IETF draft-ietf-secsh-filexfer. sftp-server is a subsystem for sshd(1M) and must not be run directly. There are no options or config settings. To enable the sftp-server subsystem for sshd add the following to /etc/ssh/sshd_config: Subsystem sftp /usr/lib/ssh/sftp-server See sshd_config(4) for a description of the format and contents of that file. There is no relationship between the protocol used by sftp-server and the FTP protocol (RFC 959) provided by in.ftpd. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
/usr/lib/sftp-server ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsshdu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
sftp(1), ssh(1), ssh-add(1), ssh-keygen(1), sshd(1M), sshd_config(4), attributes(5) To view license terms, attribution, and copyright for OpenSSH, the default path is /var/sadm/pkg/SUNWsshdr/install/copyright. If the Solaris operating environment has been installed anywhere other than the default, modify the given path to access the file at the installed location. AUTHOR
Markus Friedl SunOS 5.10 30 Jul 2003 sftp-server(1M)