|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
auto ftping
can someone give me a bash-script example of auto ftping a file from a site.
let's say 'foo.bar.com' is the site, 'passwd' is the password, and the file is 'somefile.gz' [edit:] "Give me a script and I can do it once, teach me to script and I can do it forever." it's easy to call the ftp program `ftp foo.bar.com` But, once connected, how do I pass values to the ftp program such as username and password. Since this script is going to be running itself, by process of cron, I cannot make it so that I have to be there to enter those commands at the ftp prompt. Can this be done? [/edit] thanks
__________________
Some day I'll create a smart quote to put here. Last edited by kubicon : September 18th, 2003 at 02:17 PM. |
|
#2
|
||||
|
||||
|
look at ncftpput, part of ncftp, a very, very good FTP client.
|
|
#3
|
|||
|
|||
|
or consider that ftp is not what you want! there's a package for remote, secure synchronization of directories called rdiff-backup:
http://rdiff-backup.stanford.edu/ this may be a better solution for you than ftp. |
|
#4
|
|||
|
|||
|
And if you, after all this (good!) advice, still want to use ftp and a script, here are the basics:
Code:
#!/bin/bash cd /your/download/directory ftp -n -i <<-here open foo.bar.com user <user> <passwd> bin get somefile.gz bye here |
|
#5
|
||||
|
||||
|
Or, my favorite, rsync over ssh on hosts that have exchanged public keys. . .
|
|
#6
|
||||
|
||||
|
> And if you, after all this (good!) advice, still want to use ftp and a script, here are the basics
Is it good advice because ftping this way (the way that I want) is bad? what does this does: <<-here , as in ftp -n -i <<-here |
|
#7
|
|||
|
|||
|
The other advice is good because they are mostly concerned with security (and ncftp is a very good ftpclient).
I could start a discussion about security and its importants, but I won't. Bottom line is: Try to set up your box as secure as possible. Ok question number 2, the '<<-here' thingie: These are called 'here-documents'. They are meant to be used within shell scripts (although it will work from the command line, but is kinda useless). They let you specify 'batch' input to a program. It works like this: program <<-label commands that program understands label After program is started, everything between <<-label and label is given to program Ok, let's take the ftp script and explain a 'real' example: ftp -n -i <<-here #Start ftp, with -i, -n and give lines between <<-here and here to the ftp program open foo.bar.com # Connect to (open) site user <user> <passwd> # Give user and password bin # Set transfer type get somefile.gz # Download the file bye # Close ftp connection here # we are done Last edited by druuna : September 19th, 2003 at 04:52 AM. |
|
#8
|
||||
|
||||
|
awesome! This is exaclty was I was looking for. Thanks alot.
|
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > auto ftping |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|