Is it possible to use CRON to upload a file via FTP? If yes how can I call FTP to run an upload?
A:
You probably are looking for a program called "expect" which is designed for dealing with interactive processes.
If you have "cron", you likely already have "expect" as well, these days.
smcameron
2009-06-26 02:19:47
A:
Just create your CRON jobs to call WGET to upload or download your file via FTP!
backslash17
2009-06-26 02:20:09
Actually, you'd rather want to use wput(http://wput.sourceforge.net/) to put stuff on the remote server.
tomzx
2009-06-26 02:34:46
A:
You may use ncftp -- they have an handy tools called "ncftpput"
It is easier then using expect -- it is just a single command with useful return code.
J-16 SDiZ
2009-06-26 02:28:09
+1
A:
Assuming a UNIX-like operating system you could setup a cron job that pointed to a shell script like the following:
#!/bin/sh
cd [source directory]
ftp -n [destination host]<<END
user [user] [password]
put [source file]
quit
END
Depending on your ftp client defaults and the source file type you may need to specify binary
prior to the put
.
Jay Igor
2009-06-26 02:37:50
A:
Schedule a script call from cron
.
In the script,
- Use Public Key Authentication to open a Secure FTP communication with your server
- Execute a batch file of
PUT
s to your server (there is a-b
option insftp
)
For this,
- you will need to setup the public key authentication between the server and your client,machine.
- you will need a
sftp
client on the client machine (there are clients for all platforms -- PuTTY, Winscp.net, unix variants usually have this already installed). - finally, try the PUT manually with public key authentication and note down the commands -- you can write them down in to the batch file for automation
Some other notes.
expect
is an overkill for this requirement.- More over, any scheme that requires the password to be scripted is bad
ncftp
is good for an interactive session (not such automation)- I do not know if
wput
allows public key authentication (probably not), in which case its not good for such automation either
nik
2009-06-26 04:59:00