Results 1 to 2 of 2
hi all,
"/1/2/3/report" needs to be ftp to another server, and renamed from "report" to "3"
the script below is able to ftp over the files, but does not rename ...
- 07-26-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 1
ftp to another server and rename same file from different folder
hi all,
"/1/2/3/report" needs to be ftp to another server, and renamed from "report" to "3"
the script below is able to ftp over the files, but does not rename them as what i need. Anyone able to help me?
#!/bin/sh
#
# Description:
# This script copies multiple files from multiple directories
# into a single directory.
#
# Ex: File "test1.txt" from folders "ABC", "123" and "XYZ"
# into "ALLTEST" folder.
#
HOST='hostname'
USER='username'
PASSWD='password'
#
# Log output of found files to a file named "report-list"
#
find /1/2/3 -name "report" > /1/2/3/report-list
#
# FTP commands appended into "ftpfile" because
# FTP cannot understand scripting
#
echo "ftp -n $HOST << END_SCRIPT" > /1/2/3/ftpfile
echo "quote USER $USER" >> /1/2/3/ftpfile
echo "quote PASS $PASSWD" >> /1/2/3/ftpfile
echo "bin" >> /1/2/3/ftpfile
echo "prompt" >> /1/2/3/ftpfile
echo "cd UReport" >> /1/2/3/ftpfile
echo "cd IR005" >> /1/2/3/ftpfile
#
# Read from "report-list" file
#
exec 3</1/2/3/report-list
while :; do
read filename <&3
file=`basename $filename`
path=`dirname $filename`
#
# Stop when end of file
#
if [ -z "$filename" ]; then break; fi
echo "lcd $path" >> /1/2/3/ftpfile
echo "put $file" >> /1/2/3/ftpfile
done
#
# Close the "report-list" file
#
exec 3<&-
#
# Close FTP session
#
echo "bye" >> /1/2/3/ftpfile
echo "END_SCRIPT" >> /1/2/3/ftpfile
chmod +x /1/2/3/ftpfile
/1/2/3/ftpfile # execute the ftp
- 07-26-2007 #2Linux User
- Join Date
- Jun 2007
- Posts
- 318
Why not use ftp's rename command:
if [ -z "$filename" ]; then break; fi
echo "lcd $path" >> /1/2/3/ftpfile
echo "put $file" >> /1/2/3/ftpfile
echo "rename $file 3 >> /1/2/3/ftpfile"
done


Reply With Quote