i want to write a shell script function that will ftp the files passed in the command line . i have written a shell script for ftp but how will it do for all files passed in command line argument ,
i am passing 4 files as argument
./ftp.sh file1 file2 file3 file4
code written by me :---
if [ $# -eq 0 ]
then
echo "Enter the files to be ftp as Arugment:- "
exit 1
fi
echo " "
echo "$@"
hostname="someip"
username="root"
password="root"
ftpbuild(){
sftp $hostname <<EOF
cd /tmp
mput $1 or $* ( getting error for both )
quit
EOF
}
ftpbuild - calling the function here .
getting error and not getting ftped .
do i need to declare any array here for i will use for loop for this . but if i will use for loop then for 5 files it will call the function 5 five as ftp connection ,.,
Help me out here