FTP a File to a Remote Server

Hi,
I'm fairly new to Linux and need help with a script to ftp a .csv file to a remote server. I can ftp the .csv file manually from my server to the remote server in the "/" location.

When I execute the script I receive the following message Could not create file.

Here's what I have for the script so far.

#!/bin/ksh
HOST='IP Address of Host Server'
USER='Username'
PASSWD='Password'
FILE='location of the .csv file on my server'
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
exit 0

Thanks in advance for your assistance!

You may not have write permission on "/" folder on $HOST :slight_smile:

Will FTP not try to put the file in the same location on the remote server?

Try:

FILE='location of the .csv file on my server'
...
ftp ...
bin
...
put $FILE ${FILE##*/}
...

Would it matter regarding the permission if I was able to manually copy the file over to the server?

So does that mean that I need to contact the vendor that has the host server?

Thanks!

@Scott: Thanks for spotting it.

@Computergal: say you are trying to transfer /root/myfolder/this_directory/csv_files/test.csv to your remote server.

On executing the FTP commands, the FTP will try to put the file in /root/myfolder/this_directory/csv_files/ directory rather than /

Scott's suggestion should help you.

Okay. No problem. I will try that. Thanks everyone for your help!