Click to See Complete Forum and Search --> : H. T. write shell script to run ftp and get a file for backups


Ethan
06-12-2001, 02:44 PM
Hi Linux geniuses. I have two Linux boxes running -- "main" and "secondary". I'd like to write a shell script on secondary that will switch to a backups directory, and then
1. Run ftp and connect to "main"
2. get a file from there
3. compress the file and give it a name that includes the date and time
I'd like to make it a chron job so I can have automatic daily backups of a database.
If anyone can give suggest some code that would do this I'd be totally stoked. A little explanation would be helpful too, because I'm very new to shell scripting.
One thing about this that confuses me is what happens when you go into ftp. If you have a command in your script that says, "run ftp", then is the next command in your script interpreted by the shell or by ftp? Is there a way to say, "shell, chill, I'm talking to ftp"?

Thanks

Ethan

EscapeCharacter
06-12-2001, 06:26 PM
well take look at expect and autoexpect they will help out a great deal doing this type of thing. then after the script is done make it a cron job and sleep easy

Craig McPherson
06-12-2001, 08:12 PM
Yes... shell scripts are only for non-interactive processes. You have to use expect if you want to write scripts that interact with interactive processes, like FTP. But it's fairly simple: there's a section about expect in the Unix System Administration Handbook, if you don't have access to one of those, try searching Google for an Expect tutorial...