Hi,
I need to create a script that checks if a file exists on an offsite server
which only has ftp enabled. I was originally going to use perls Net::FTP
class but the client does not have perl installed nor wants it.
So, I have to use a shell script which logs into the server, then
checks if different files exist in multiple directories.
Basically, all I need to do is check if the file exists in these directories
but redirect output to a log file which I could bring back to my main
server for further processing.
Here's what I have so far:
FtpUser="username"
FtpPswd="mypassword"
HostName="hostname"
FTPFile1="/u/backups/remotefile1"
FTPFile2="/u/backups/remotefile2"
( echo "user ${FtpUser} ${FtpPswd}
ls $FTPFile1
ls $FTPFile2
bye" ) | ftp -n ${HostName}
-
How can i capture the output of ls to a file either on the remote or
current server? and (this script will be placed in root's crontab) -
Can I place the FTPFile{n} variable assignments into another file,
and use a while statement to read the lines 1 by 1 ... without having
to close the connection each time?
Hope I've explained this clearly.
Thank you!
G
---------- Post updated at 05:19 PM ---------- Previous update was at 04:00 PM ----------
Stupid me ... I figured i could just redirect the ftp output to
the local machine at the end of my ftp command.
But, can anyone help me with my 2nd question?
Thanks!
G