FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 18th, 2003, 02:02 PM
kubicon's Avatar
kubicon kubicon is offline
pogremar
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: At Work
Posts: 945 kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 14 h 50 m 47 sec
Reputation Power: 7
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.

Reply With Quote
  #2  
Old September 18th, 2003, 02:59 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,632 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 12 m 33 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
look at ncftpput, part of ncftp, a very, very good FTP client.

Reply With Quote
  #3  
Old September 18th, 2003, 04:29 PM
frymaster frymaster is offline
hubris, loathing, technology
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: http://frymaster.ca
Posts: 76 frymaster User rank is Private First Class (20 - 50 Reputation Level)frymaster User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 27 m 57 sec
Reputation Power: 8
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.

Reply With Quote
  #4  
Old September 18th, 2003, 04:51 PM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old September 18th, 2003, 06:41 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,632 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 12 m 33 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
Or, my favorite, rsync over ssh on hosts that have exchanged public keys. . .

Reply With Quote
  #6  
Old September 18th, 2003, 07:26 PM
kubicon's Avatar
kubicon kubicon is offline
pogremar
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: At Work
Posts: 945 kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 14 h 50 m 47 sec
Reputation Power: 7
> 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

Reply With Quote
  #7  
Old September 19th, 2003, 04:50 AM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
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.

Reply With Quote
  #8  
Old September 19th, 2003, 10:27 AM
kubicon's Avatar
kubicon kubicon is offline
pogremar
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: At Work
Posts: 945 kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level)kubicon User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 14 h 50 m 47 sec
Reputation Power: 7
awesome! This is exaclty was I was looking for. Thanks alot.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > auto ftping


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway