Click to See Complete Forum and Search --> : Backing up data offsite


Jason Gorman
10-26-2001, 03:49 PM
I need to back up some data to an offsite web server. I want to do this via ftp, but my scripting skills are not up to par. Can anyone send me in the right direction?

Thanks! :)

Joeri Sebrechts
10-26-2001, 04:17 PM
Originally posted by Jason Gorman:
<STRONG>I need to back up some data to an offsite web server. I want to do this via ftp, but my scripting skills are not up to par. Can anyone send me in the right direction?


Thanks! :)</STRONG>

you can't script regular ftp, you need ncftp, which has separate get and put commands that can be used from the shell.

If you want to learn more about scripting, reading the man page of your shell is a good start.

AdaHacker
10-26-2001, 06:19 PM
Originally posted by Joeri Sebrechts:
<STRONG>you can't script regular ftp...</STRONG>

Sure you can. It's called input redirection, and it may not be the prettiest way, but it's effective. All you need to do is write a script that will print the ftp commands you would normally type in interactively to standard output. (Or you could just put them in a text file if they aren't going to change.) For example:
#!/bin/csh
# Call this file backup.ftp
# Note: I make no promises about my syntax
echo "open ftp.whatever.com"
echo "account me"
foreach file (`ls *.c`)
echo "put $file"
end
echo "ls"
echo "quit"
would upload all the .c files in the directory. Just call it with
ftp &lt; `backup.ftp`
It's a little weird at first, but not that hard once you get used to it. Just read the man pages for ftp and your favorite shell.
I've never heard of ncftp, but it sounds like you may want to try that if you're looking to do anything terribly complicated.

[ 26 October 2001: Message edited by: AdaHacker ]

thedexman
10-26-2001, 07:12 PM
Heiner's SHELLdorado is a pretty decent resource for neat and useful shell scripts. He's even got a korn shell HTTP server for crying out loud.
http://www.oase-shareware.org/shell/