Forum Moderators: bakedjake

Message Too Old, No Replies

Is it possible to set up an automated FTP on a Cron job?

Unix question

         

Clark

5:47 pm on May 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it possible to set up a whole FTP operation within a Cron job? Any ideas how to do this?

Funnily enough, using windows NT you can set up a file with the FTP commands, including the userid and password and pass it onto the AT scheduler. But I don't know how to achieve this with unix.

Thanks.

drbrain

5:51 pm on May 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you'd just need the passwords and so-forth to tell your ftp client where to get/send files to. There are a variety of tools to do this, wget springs to my mind first.

May require a bit of scripting.

Clark

5:54 pm on May 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, is wget a unix command? Or something I have to compile? (never compiled anything in my life).

drbrain

6:27 pm on May 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[wget.org ]

It may already be on your system, it is a very popular tool. You may also be able to find binaries for your platform. (Doesn't seem to support upload though, but there are other tools for that, maybe even ftp can do it (depending on version), check your man pages.)

rayvd

6:30 pm on May 9, 2003 (gmt 0)

10+ Year Member



You can use the ftp command and pipe the PUT, GET stuff to it from a shell script. Definitely a possibility. I have also used Python's ftp library to do transfers on occasion. It's pretty straightforward if you have any programming experience.

Clark

7:22 pm on May 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks guys. I've been fooling around with wget and it seems to be a great alternative. The problem is, when I use a command line ftp from my windows machine, the user name and pass works fine. When I do an ftp from my shell on the unix box, the same password doesn't work. I don't get it. Same for wget from the unix shell :(

marcs

7:32 pm on May 9, 2003 (gmt 0)

10+ Year Member



The ncftp set of tools/commands is great for this type of thing.

I'm using ncftpput in a cronjob to upload a file to a remote server via FTP daily, for example.

Clark

7:38 pm on May 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ncftp fails for me as well. So strange, using a browser: fine. Using windows: fine. Using *any* unix tool, authentication failed. I can't understand it!

rayvd

5:43 pm on May 13, 2003 (gmt 0)

10+ Year Member



Are you providing the username and password to the wget/ncftp utilities? Otherwise they'll try to log on as anonymous... also, are you firewalled? Web browsers generally use passive FTP mode by default, whereas most likely ncftp and wget are using the standard port-based method. This could cause problems too if you're behind a router or server that is doing NAT. You may need to enable passive mode for ncftp/wget (although this shouldn't result in an authentication error).