Modify FTP script to have SCP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Modify FTP script to have SCP
# 1  
Old 04-26-2006
Modify FTP script to have SCP

Hi,

I have an existing FTP script and I am trying to modify this to do SCP rather than FTP. I checked the man help in SCP and still having a hard time doing this...

Current FTP script..

ftp -n << EOF > $LOG_FILE
verbose
open ${SERVER}
$LOGON
cd ${REMOTE_FILE_PATH}
get ${REMOTE_FILE_NAME}
close
bye

EOF


LOG_FILE, SERVER, LOGON, REMOTE_FILE_PATH are parameters passed to it.
LOGON has the userid and password for that particular server.

The SCP script that I am trying to do is..

scp -v << EOF > $LOG_FILE
open ${SERVER}
$LOGON
cd ${REMOTE_FILE_PATH}
get ${REMOTE_FILE_NAME}
close
bye

EOF


I couldn't find the relative -n parameter in SCP...But verbose in FTP can be replaced by -v.

I would appreciate any help in this..

Thank You,
Madhu
# 2  
Old 04-26-2006
I need second set of eyes in looking at my problem...I finally did achieve the sftp working....But the script is not executing the "success" statements at the end...I am sure I am doing something silly here.. Smilie

#!/usr/bin/ksh

SERVER=$1
REMOTE_FILE_PATH=$2

LOCAL_FILE_PATH=/local3/Projects/dev/scripts
LOG_FILE=$LOCAL_FILE_PATH/sftpPullFiles_log${RUNTIME}

file_count=`expr $# - 2`
echo "Total files to be sftped : ${file_count} "

cd ${LOCAL_FILE_PATH}

#------------------------------------------------------
# File 1
#------------------------------------------------------


REMOTE_FILE_NAME=$3
sftp -b /dev/fd/0 ${SERVER} <<EOF > $LOG_FILE
cd ${REMOTE_FILE_PATH}
get ${REMOTE_FILE_NAME}
bye
EOF

files_trnsf=`grep ^"${REMOTE_FILE_NAME} " ${LOG_FILE}`

if [ "$files_trnsf" -eq 1 ]
then
echo "File ${REMOTE_FILE_NAME} SFTPed Successfully from ${SERVER}"
rm ${LOG_FILE}
else
echo "ERROR occured while SFTPing file ${REMOTE_FILE_NAME} from ${SERVER}."
echo "See log ${LOG_FILE} for details"
exit 1
fi


if [ "$file_count" -eq 1 ]
then
exit 0
fi
# 3  
Old 04-26-2006
Yeppp.........I did get it...
I changed the

if [ "$files_trnsf" -eq 1 ]

to

if [ "$files_trnsf" -eq 0 ]

and it worked....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP - SCP

Hi Team, When an FTP is success, code 226 is returned. Is there a possibility of return of code 226, when a part of file is transmitted to remote server. SCP do not return any codes but exit with status 0. This is what i found after executing SCP with verbose option. Is there a possibily... (2 Replies)
Discussion started by: forums123456
2 Replies

2. Shell Programming and Scripting

FTP/SFTP/SCP Files

Hi, I have a process which FTP's the files from one server to another server. Sometimes only half or a part of the file is delivered to remote location, but on the end log says FTP is successful. But ideally file in full is not delivered to remote location. How can i catch these kind of errors... (2 Replies)
Discussion started by: forums123456
2 Replies

3. Shell Programming and Scripting

how can I modify this script.

hello forum members, I have a script which is used find the Uname and passwords and redirects into a output.txt file.I hardcoded a string "ciadev" but iwant search two more strings also "absdev" and "absprod" So modify this script please. I am lookinmg forward from you, please find the below... (2 Replies)
Discussion started by: rajkumar_g
2 Replies

4. UNIX for Dummies Questions & Answers

Ftp/scp Command Error

Hi, How to use ftp/scp command with password containing @ symbol. Ex: ftp xyz:xyz@sun@11.211.111.11:/export/backups/ Exception I got: unknown host or invalid literal address Note: I dont want to change the password. Regards, Vinodh' Kumar (5 Replies)
Discussion started by: vino_hymi
5 Replies

5. Linux

Need SCP script equivalent to FTP script .

Hi, Currently i'm using the folllowing FTP acript and its working. echo "open $server" > ftp_file echo "user $user $password" >> ftp_file echo "cd $remote_dir" >> ftp_file echo "lcd $local_dir" >> ftp_file echo "put $file">> ftp_file echo "bye" >> ftp_file ftp -nv < ftp_file I've... (1 Reply)
Discussion started by: vickramshetty
1 Replies

6. UNIX for Advanced & Expert Users

problem while doing Large file transfer thru Scp and FTP

Hi , I want to transfer one file having 6GB(after compression) which is in .cpk format from one server to other server. I tried scp command as well as FTP and also split the file then transfer the files thru scp command. At last i am facing the data lost and connection lost issue. Generally it... (2 Replies)
Discussion started by: Sumit sarangi
2 Replies

7. UNIX for Dummies Questions & Answers

SCP -r from Secure FTP site

Hi all, My problem is simple. I would like to download the contents of a directory on an ftp site. I can access the site through windows, but there are many files and it would be too tedious to click and download each file. Thus, I am trying to use scp -r... (5 Replies)
Discussion started by: cpabrego
5 Replies

8. Shell Programming and Scripting

Please help to modify my script

Hi, I have a script which connect to ATM's and pull two files from the ATM. The which i try to pull is like PIC20085200001*.JPG First 7 digit consist of year montn and date as well After todays execution i want to change the date to next date I add few lines in the script but it is not... (6 Replies)
Discussion started by: Renjesh
6 Replies

9. Shell Programming and Scripting

Replace FTP with SCP

Hi All, I was using FTP for transferring files from remotemachine. Code below: # FTP for Customercare log #************************* cd $TRACKING_LOGDIR ftp -n $CUSTCARE_SERVER << END_INPUT >> $TRACKING_LOGDIR/ftp_custcare.log 2>&1 user $CUSTCARE_USER $CUSTCARE_PWD asc cd... (3 Replies)
Discussion started by: subin_bala
3 Replies

10. Shell Programming and Scripting

Modify Perl script to work with txt - Permissions script

Hi I have this code, and i want work with a ls -shalR output in .txt What i need read to do this?? Where start? #!/usr/bin/perl # Allrights- A perl tool for making backups of file permissions # Copyright (C) 2005 Norbert Klein <norbert@acodedb.com> # This program is free... (1 Reply)
Discussion started by: joangopan
1 Replies
Login or Register to Ask a Question