Hi Everybody,
I am working on FTP Script (i,e Parser.sh,Upload.sh) and the contents of the same are mentioned below ..,
#!/bin/bash
if [ $# != 6 ]; then
echo "Usage
./Parser.sh IP USERNAME PASSWORD SOURCE FILENAME DESTINATION
where
IP ------------- IP address of remote server
USERNAME-------- username with which to establish ftp session
PASSWORD-------- password for the above mentioned USERNAME
SOURCE --------- source directory
FILENAME ------- name of the file to be ftped
DESTINATION----- path at remote directory at which file is to be kept"
exit
fi
HOME=/home/modula/itprod1/Prasanth # home directory
DESTINATION=$5
DIRECTORY=$4
LOG=$HOME/LOG
EXPECTED_RETURN="221 Goodbye"
LIST_OF_FILES=list_of_files
cd $DIRECTORY
echo $DIRECTORY
ls -lrt $5 >$LIST_OF_FILES
cat $LIST_OF_FILES | while read LINE
do
filename=`echo $LINE|awk '{print $9}'`
size=`echo $LINE|awk '{print $5}'`
if [ "$filename" = "" ]; then
filename=temp
elif [ "$filename" = "_" ]; then
filename=temp
else
echo "Transfering .....$filename"
# FTP Process Script
cd $HOME/
sh Upload.sh $filename $1 $2 $3 $6 > $LOG/ftp_log
RETURN=`fgrep "221 Goodbye" $LOG/ftp_log`
if [ "$RETURN" = "${EXPECTED_RETURN}" ]
then
mv $DIRECTORY/$filename $DIRECTORY/$filename.Done
else
echo "Unable to establish connection"
fi
fi
done
#!/bin/bash
FILE=$1
IP=$2
USER=$3
PASS=$4
DESTINATION=$5
ftp -inv $IP<< !EOF
user $USER $PASS
cd $DESTINATION
prompt
bin
put $FILE Temp_$FILE
rename Temp_$FILE $FILE
quit
!EOF
When i carry out the functionality of Parser.sh,i am getting follwoing error ..,
itprod1[68]:/home/modula/itprod1/Prasanth>sh -x Parser.sh 192.168.60.10 satyam trick$# SOURCE hosts.txt ALERT
Variable syntax
itprod1[68]:/home/modula/itprod1/Prasanth>
Can anyone help me on the same at the earliest?