![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
thanks again.. this is what i have for the script (after wrestling with Vi for about half an hour.)
text nested in /* */ is not actually in the script, these are my questions to the forum... #!/usr/bin/ksh /* is this neccessary, or can i run it in the default shell?*/ HOST=10.0.0.3 USER=root PASSWD=***** /* what exactly do these two lines do? */ exec4>&1 ftp -nv >&4 2>&4 |& print -p open $HOST print -p user $USER $PASSWD print -p cd / print -p cd /u/home print -p lc .. print -p binary print -p put rwc8.tar.gz wait /* does this wait until the ftp completes, or is it expecting a number? */ exit 0 i pretty much copied exactly what perderabo posted a few replies up... two questions: 1) is it ok to run this job as root or should i create an ftp user for this task??? i really dont like the fact that the root password is in clear text in this script.. if someone stumbled across it and opened it they would have the root pw.. 2) i would like the daemon to send me a mail with the results job.. the text that is spit out when the ftp session completes would be fine, just so i know how much data was transferred. thanks again.. e0- |
|
|||||
|
auto - ftp
The script must run as ksh since you are
using ksh built-in's (print) and capabilities. I would set up a new user to run this as. You may have problems logging in as root via ftp on the remote unless you have configured the remote to allow this (I try to avoid using root where ever possible). Check out the "tee" command to set up a " | mail someuser@somehost.com" The "wait" will wait for the child(s) to complete. |
|
||||
|
Quote:
I tried your script .. somehow it doesnt work with SFTP it still asks for password...... #!/usr/bin/ksh exec 4>&1 sftp user@host >&4 2>&4 |& print -p cd directory print -p put test wait exit 0 ~ Any suggestions? |
|
||||
|
Quote:
I tried your script .. somehow it doesnt work with SFTP it still asks for password...... #!/usr/bin/ksh exec 4>&1 sftp user@host >&4 2>&4 |& print -p cd outgoing print -p put test1 wait exit 0 ~ Any suggestions? |
|
||||
|
I would use Perl. Any version newer that 5.0x has the necessary Net::FTP module.
#!/usr/bin/perl use Net::FTP; $ftp = Net::FTP->new("MACHINE_NAME", Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login("USER_NAME",'PASSWORD') or die "Cannot login ", $ftp->message; $ftp->cwd("/pub") or die "Cannot change working directory ", $ftp->message; $ftp->get("that_file.tar.gz") or die "get failed ", $ftp->message; $ftp->quit; You could then stuff this into the user cron. Hard coding the username and password does present obvious security issues. If you're interested in Perl, check out cpan.org and perlmonks.org http://search.cpan.org/~gbarr/libnet-1.19/Net/FTP.pm |
|
||||
|
Does this option allow for getting a specific file? What I am looking for is to ftp the log from the previous day that is in YYYYMMDD.log format. I don't wnat to use the mget and keep transfering the older logs as well.
Thx for any updates. Scott |
|
||||
|
Thank you very much
Thank you very much for the explanation and example of this script. I had to install korn shell for the command interpreter, but at 330KB I think I can spare the diskspace.
Here is a link to my application of this. NASLite server Rick D. Brockville, Canada |
![]() |
| Bookmarks |
| Tags |
| linux, mtime, sendmail |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|