FTP - shell script question

Hi All,

I had a question on something which i have trying to add to my current shell script which does FTP of files from my local machine to a remote server.

I have 5 files which i zip and FTP them on daily basis to a remote server. My script is as below:
############################
#!/bin/sh
temp="put $1"
ftp xxxx.this is IP address of remote machine.com << EOFFile
myusername
binary
$temp
quit
EOFFile
exit 0
############################

I am successfull in doing this activity.

But sometimes there is some problem with the remote FTP machine the FTP fails.

My problem is that i am only able to determine this failure after manually logging in checking for the files on remote machine.

My remote files look like this on FTP machine, all the files have the same name each day and The system date of this matches with the local machine:

08-31-08 10:00PM 55182 help1.zip
08-31-08 10:00PM 64861 help2.zip
08-31-08 10:00PM 57915 help3.zip
08-31-08 10:01PM 224245 help4.zip
08-31-08 10:01PM 2388 help5.zip

Is there a way i can add in my script or have an external script that checks for these files on FTP machine( probablly compare with local machine date stamp and FTP date stamp to determine the latest files are there).

Please suggest

Thanks,
Sandy

One option shoud be ..

After copying files to remote server, just before quit the connection, give a ls and capture it in a shell variable.Then, verify the files list from the variable...

ie,

var=$(ftp xxxx.this is IP address of remote machine.com << EOFFile 
......
...
lcd
ls
quit
EOFfile
)

echo $var

The ftp command is designed for interactive use.

For scripts, use the ncftp group of commands, or, if possible, use scp.

Hi dennis,

#!/bin/sh
var=$(ftp www.state.il.us << EOFFile
symphems
binary
ls
quit
EOFfile
)

This gives me the required results but the results of echo $var is as below:
11:52PM 61954 help1.zip 09-02-08 10:01PM 8153 help2.zip 09-02-08 10:01PM 1890 help3.zip

The results are in a single line.

Can you please help how i can have them one fter another.

Thanks,
Sandy

Assuming that you have only zip files in the location:

echo $var | sed 's/zip/zip\n/g'

or

echo $var | xargs -n4

Quote your variables:

echo "$var"

Thanks dennis

regards,
Sandy