|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| IP Networking Learn TCP/IP, Internet Protocol, Routing, Routers, Network protocols in this UNIX and Linux forum. |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Every day i ftp tar.gz a file from the production server to a back up machine.. This task creates way to much traffic on the network at the end of the day and puts and undo load on the production machine during operation hours. i would like to create a script that would automatically fire off the ftp at like 2:00 am so that the transfer occurs when there is little or no load on the network. if anyone has suggestions on how to accomplish this, PLEASE let me know...
thanks.. --e0 loworderbit@aol.com |
| Sponsored Links | ||
|
|
|
#2
|
||||
|
||||
|
auto-ftp transfers
You can set up a ".netrc" file for the
user doing the transfer then set up a cron job for that userid to run a script to actually do the FTP transfer. Check the man pages for ftp(1) and netrc(5) |
|
#3
|
||||
|
||||
|
I need to do a lot of automated ftp jobs myself. I have tried several versions of this and have finally settled on a style of script that I like. I found that using a .netrc file to automate the logging-in process kept painting me into a corner because different scripts needed to sign in as different users. So I avoid .netrc and force the script to sign in. I don't like to allocate pty's unless I really am forced into it, so I also avoid pty based tools like expect. I really like ksh so that was my tool of choice. And I like the co-process concept because it makes feeding commands into the ftp process so easy with "print -p". The only problem is that the co-process manipulates standard-out so as to make it available to "read -p". And it's too hard to know how many "read -p" I will need. So I send the output to a different file descriptor. Putting it all together: Code:
#! /usr/bin/ksh HOST=remote.host.name USER=whoever PASSWD=whatever exec 4>&1 ftp -nv >&4 2>&4 |& print -p open $HOST print -p user $USER $PASSWD print -p cd directory print -p binary print -p put tar.gz print -p bye wait exit 0 That script will tranfer the file and the output of the script will be the output from the ftp job itself. Put the script into cron and save the output so you can look at it the next morning. Last edited by Perderabo; 07-02-2004 at 08:44 AM.. |
|
#4
|
||||
|
||||
|
hmm... write a script on the server that is launched daily using the cron (man crontab)... have that script ftp to your workstation or wherever and grab the file. The automated FTP will probably require a .netrc file in your user directory or wherever you ftp to to get the file.
However, if you are having to tar the file manually every day, write a script on the workstation side to do that for you a few minutes before the server script executes... once again, utilizing the crontab. Good luck and let me know how it goes. Strange... those other replies both popped up while I was writing... ummm... take their advice. ![]() Last edited by ober5861; 08-29-2001 at 02:40 PM.. |
|
#5
|
||||
|
||||
|
Quote:
|
|
#6
|
||||
|
||||
|
Quote:
The line "ftp -nv >&4 2>&1 |&" is a little harder. The "|&" turns the process into a co-process that allows subsequent "print -p" statements to send lines to the co-process' standard-in and "read -p" to read from its standard-out. So ksh forks a copy of itself and fiddles with the fd's 0 and 1 until this it set-up. But it leaves the rest of the fd's alone. Then it encounters ">&4" which causes it to set the ftp process' standard out to whatever 4 is. Well since 4 is a copy of 1 before the co-process, we are back to writing to the original shell's standard out. Lastly, the 2>&4 does the same thing for standard error. I could've used "2>&1" at this point for the same effect. This is hard to explain, but I hope this helps. |
|
#7
|
|||
|
|||
|
Ftp
thanks for all of the help.. i guess i should have mentioned that i am running sco openserver.. i dont know if it matters or not, but the more information the better.... anyway, it looks like the best way to do this is to set up a script and use crontab..
manually, i was using the get command from the back up machine, but if its all the same, put from the production machine will work fine. now, its time to get down to the creation of the script and setting up cron to run it... my unix background is about three weeks, but i have been an (i apologize in advanced) NT admin for over a year, so please forgive my ignorance. anyway, if any of you would like to assist me in setting this up i would be very gratefull... This website, Unix: the complete reference, and sco unix in a nutshell are the only resources i have so far, so i am relying on you all a little... thanks again... e0-- |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| linux, mtime, sendmail |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| automated ftp. | sangfroid | Shell Programming and Scripting | 10 | 05-07-2007 11:52 AM |
| process vs task | hana | UNIX for Dummies Questions & Answers | 2 | 07-02-2006 06:32 PM |
| Automated FTP | shauche | UNIX for Advanced & Expert Users | 11 | 07-11-2002 02:08 AM |
| FTP automated? | n9ninchd | UNIX for Dummies Questions & Answers | 6 | 05-18-2001 10:21 AM |