Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell Script and FTP

Status
Not open for further replies.

ManagerJay

IS-IT--Management
Jul 24, 2000
302
US
I have written the following script to upload a small amount of data from our Regional Offices to our Headquarters office each night.

Backup_Name=`date | cut -c 1-3,5-7,9-10,25-28`.$HOSTNAME.tgz
tar -cvzf "/$Backup_Name" /users

ftp -n -i XXX.XXX.XXX.XXX <<SCRIPT
user XXXXXX XXXXXX
bi
put &quot;/$Backup_Name&quot; &quot;$Backup_Name&quot;
bye
SCRIPT

rm &quot;/$Backup_Name&quot; -f

The tar file is created and the data is transferred to the headquarters server, but the tar file created is not deleted.

Any ideas why the rm command is not running and what should be done to make it run correctly.

TIA,



Jay
 
ret_rm=`rm -f /$Backup_name && echo $?`

if [ &quot;$ret_rm&quot; -gt 0 ] ; then
logger &quot;Failed to rm backup file.&quot;
echo &quot;Failed to delete backup.&quot; | mail me@me.net
else
logger &quot;Removed backup file.&quot;
echo &quot;Success: delete backup.&quot; | mail me@me.net
fi
 
If you can use ncftp you will be much happier. It has modules built around command line ftp. I just did one and it work great.

john. g. lynn
 
Thanks for the help. I put ` around the ftp portion and everything is working fine now.

Thanks again.



Jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top