I am new to the shell script and i have a script which will connect to server enviornment which will read a file and will FTP to an another server location. But while executing this script FTP transfer is not occuring. But when I enter in FTP mode I am able to transfer the file from one server to another.
Script is
#!/bin/sh
FILE_NAME="/user/sba-appl/productie/sscr/ramu/dd.DAT"
HOST='130.144.240.108'
USER='user name'
PASSWD='password'
ftp -nv <<EOF
open $HOST
user $USER $PASSWD
cd /user/sba-appl/test/sscr/ramu
put $FILE_NAME
EOF
The error which I am getting is 553. The problem is I cant change the chmod permission of the target server as it is an production server. the root directory user doesnt have a write permission. But while using FTP mode I am able to write the the file but through script I am getting 553 error.Can anybody tell me how to solve this problem.Whether I can use symbolic links??. But If i am able to transfer the file using th FTP mode why it is not working with the script??
This may be an issue if your $USER actually contains a space. I would be very suprised, but it does look okay otherwise at first glance. When you put the file, I'm assuming that the full path of your file name exists below /usr/sba-appl/test/sscr/ramu too. If not, and that's where you want to put it, try splitting it up.
Perhaps I would move the $HOST to the ftp line and put some tracing in:-
#!/bin/ksh
FILE_NAME="/user/sba-appl/productie/sscr/ramu/dd.DAT"
HOST='130.144.240.108'
USER='user name'
PASSWD='password'
sourcedir=`dirname $FILE_NAME`
filename=`basename $FILE_NAME`
cd $sourcedir
ftp -nv $HOST <<EOF
user $USER $PASSWORD
status
pwd
cd /usr/sba-appl/test/sscr/ramu
pwd
dir $filename
put $filename
dir_$filename
status
EOF
Thank you very much now it is working, now I am able to see the File. But I have one more doubt . Whether can i Avoid the password prompt which is coming. If I have given the username and password as static why it is again Prompting for the password.When i checked I understand that we have to edit .netrc file but I cant acces this file in my server. Whether any other metod is there for this. This is not important but for perfection I am asking this. Thanks again for your help