The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Please help to modify my script Renjesh Shell Programming and Scripting 6 05-21-2008 05:08 AM
Modify Perl script to work with txt - Permissions script joangopan Shell Programming and Scripting 1 09-12-2007 08:38 PM
Using a script to modify the crontab johnmsucpe UNIX for Dummies Questions & Answers 2 07-07-2005 11:44 AM
Is it possible in a shell script to modify itself ?? sehgalniraj Shell Programming and Scripting 5 03-22-2005 09:21 PM
sed modify problem in script darthur UNIX for Dummies Questions & Answers 2 11-26-2002 04:53 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-26-2006
Registered User
 

Join Date: Nov 2005
Posts: 91
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
Reply With Quote
Forum Sponsor
  #2  
Old 04-26-2006
Registered User
 

Join Date: Nov 2005
Posts: 91
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..

#!/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
Reply With Quote
  #3  
Old 04-26-2006
Registered User
 

Join Date: Nov 2005
Posts: 91
Yeppp.........I did get it...
I changed the

if [ "$files_trnsf" -eq 1 ]

to

if [ "$files_trnsf" -eq 0 ]

and it worked....
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0