FTP Shell

Hi,

I know this topic is on the forum a bit but I am totally new to Unix and I am really struggling and could do with some help.

I need to write a shell script which will ftp a file from my Oracle Apps DB to a remote ftp server.

I undertand about how I can schedule it with a cron job but I just can't get the actual shell to run when I execute it.

Could anyone please put me in the direction of (or post me even) some real basic, step by step procedures of what is needed to create a shell script which will connect and put a file from Unix DB server to remote ftp- I mean really really really basic - I'd massively appreciate it.

Thanks in advance.

Check if this helps..

#!/bin/sh
HOST='hostname'
USER='yourid'
PASSWD='yourpw'
FILE='file.txt'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
exit 0

Hi,

with vi I created the file with the name ftp_test.sh and gave it '775' permissions.

I executed the file by typing sh ftp_test.sh and I received the following:-

ftp_test.sh: line 2: HOST:command not found
ftp_test.sh: line 3: USER:command not found
ftp_test.sh: line 4: PASSWD:command not found
ftp_test.sh: line 5: FILE:command not found
not connected
not connected

Do you think I've typed it wrong or something?

You can do like this as well

echo
(
echo "open $IP"
echo "user $USER $PASSWD"
echo "put $File_name"
echo "verbose"
echo "bye"
) | ftp -inv

Post your script so we can see what the problem might be.

Hi,

worked out what I was doing wrong in the first issue - I was leaving a space where I shouldn't have i.e. HOST = 'hostname' and not HOST='hostname' as it should be. Also, I was getting what I thought was an error message saying KERBEROS_V4 authentication error or something - but it has worked now.

Thank you!