Your own personal wrang-wrang (darth_spacey) wrote in rhlinux,
Your own personal wrang-wrang
darth_spacey
rhlinux

Piping a script to FTP?

I have a script something like
user root hackme
cd /pub/media
lcd /mp3
mget *.mp3
quit


I'm trying to pipe it to ftp via cat ftpscript |ftp -in foo (so I can automate it via a script called from cron), but when I try that, it returns me immediately to the command line, rather than running ftp and accepting the script as standard input. The man page for ftp does not state that it does anything unusual with stdio.

What am I doing wrong? How can I do it right?

Thanks for your time,
  • Post a new comment

    Error

    default userpic
  • 3 comments
You might try using either ncftp (or some other command line ftp tool) or expect.
It's been a while since I've done FTP scripting, but the first thing that comes to mind os to try getting rid of the user command and putting an entry into your .netrc file. There should be a netrc man page to describe the format.
I second that .netrc suggestion. Alternately you can use wget if you're only doing gets. That supports a username/password.