Hi,
I just need a shell script that copies a list of files from a directory in a remote server to my current directory at local server
the remote server may contain the following list:
/root/pradeep/myfiles/default
/root/pradeep/myfiles/dir1
/root/pradeep/myfiles/dir2
...
/root/pradeep/myfiles/dir10
the following are the conditions:
1) the mandatory parameters to the script are <server name> < userid> < password>
if this is given it should copy all the file in a directory /root/pradeep/myfiles/default
to my local system
2) if the fourth option is mentioned, that should be any directory name in /root/pradeep/myfiles/
the script should copies all the files in that directory
to my current directory
thanking you in advance
---------- Post updated at 09:46 AM ---------- Previous update was at 09:39 AM ----------
Actually i used the following script...unfortunatley if-condiiton is not supported in the FTP script i used what to do??? plz help me
#!/bin/bash
##
##Script to load FILES
if [ $# -lt 3 -a $# -gt 4 ] ; then
echo "please enter the command properly"
echo " "
echo "Usage: <Script_name><server><user_name><password>[<version>]"
echo "example: sh pradeep.sh server1 root root123 10.2.1.5"
echo "try again"
exit -1
elif [ $# -eq 3 ] ; then
hostname=$1
username=$2
password=$3
ftp -n -i $hostname <<END_SCRIPT
quote USER $username
quote PASS $password
bin
cd /root/pradeep/myfiles/default
mget *.rpm
END_SCRIPT
elif [ $# -eq 4 ] ; then
hostname=$1
username=$2
password=$3
ftp -n -i $hostname <<END_SCRIPT
quote USER $username
quote PASS $password
bin
cd /root/pradeep/myfiles
ls -l | grep "$4" > /temp/available.$$
temps =`cat /temp/available.$$`
if [ " $temps " == "" ] ; then
cd /root/pradeep/myfiles/$4
mget *.rpm
else
echo "Sorry the required file doesnt exit's"
fi
END_SCRIPT
fi