Automated FTP task


 
Thread Tools Search this Thread
Special Forums IP Networking Automated FTP task
# 8  
Old 08-29-2001
Vi

anyone else remember using Vi for the first time??? is this our only option???

e0-

Vi hater
# 9  
Old 08-29-2001
vi

Well... I first started using it 17 years ago
and all I can remember is that it was 1000 times
better than "ed" Smilie

You do have emacs as another option but I
don't think you'll like that much better.

If you have X, you should be able to find
a X text editor (perhaps pretty basic).

The thing about vi is that you can pretty much
find it on any **IX system. Anything else and
all bets are off.

I'm sure you could find a substitute on the net
somwhere but I've never looked for one myself.

Sorry about that Smilie
# 10  
Old 08-30-2001

If you're using Linux, or have pine installed, look for pico. In any case, I too would recommend vi. Again, if you on a Linux system, and vim is installed (Vi IMproved), try the command vimtutor.

HTH
# 11  
Old 08-30-2001
First off, thanks for explaining that Perderabo! I thought that was all dealing with fds, but I wasn't sure. I love this forum...

As far as editors, vi is probably the most powerful, but one of the hardest to get used to... I myself used to be a vi hater...

But there are several text editors available... kwrite (kde), pico, joe... the possibilties are endless. Several of them will color code scripts as you write them too. It's really quite fun! ... hmm... does that make me a nerd?

Anyways, don't forget crontab -e to edit your crontab. It will use whatever you have the $EDITOR set to.

In case you didn't know, here's the syntax for crontab:

MIN HOUR DAY MONTH DAYOFWEEK COMMAND

ie. 5 2 * * * /home/username/bin/script

That will run your script every day, at 5 after 2 in the morning.

Good luck and don't be afraid to ask questions.
# 12  
Old 08-30-2001
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-
# 13  
Old 08-30-2001
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.
# 14  
Old 06-23-2004
Quote:
Originally posted by Perderabo
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

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.
Hi:
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automated FTP

Hello,I just know the basics of scripting & I need a script to automate ftp since I use it quite often. I use ftp to transfer different kind of files and everytime the source & the destination directories are different for transferring files, so can anyone help me out on this urgently.. (2 Replies)
Discussion started by: mohit_02mar
2 Replies

2. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

3. Shell Programming and Scripting

Automated FTP

I want to do Automated FTP from linux client to LINUX server using a shell script after every one hour. And copies last most updated file from Linux server. OR You can say that whenever files get modified on LINUX server so it also copies on my LINUX client. Linux SERVER path=... (4 Replies)
Discussion started by: wakhan
4 Replies

4. Shell Programming and Scripting

how to devlop automated FTP in UNIX

Automated FTP. hint : use 'atd' to schedule to run a specific script. An Env Variable should be created,say CONF_DIR which points to some dir. @ some time, create a TAR file of this and FTP it to some server. (3 Replies)
Discussion started by: vishalzone2002
3 Replies

5. Shell Programming and Scripting

automated ftp.

Hi I am trying to delete some specific files ( files other than created today) from the server on a cron basis. I wrote a small script, but I am stuck up in how to delete only specific files. #!/usr/bin/expect -f set IP set timeout -1 spawn ftp $IP expect ): send "username\n"... (10 Replies)
Discussion started by: sangfroid
10 Replies

6. IP Networking

Automated ftp for Multiple files

I have seen the script posted yesterday for automated ftp Can we do some thing like ftp ing multiple files in one script Example input.txt has all files names to be ftped input.txt ------ a.tar b.ccp c.perl i need to ftp all the files present in input.txt i tried something like... (0 Replies)
Discussion started by: pbsrinivas
0 Replies

7. UNIX for Dummies Questions & Answers

one time automated ftp session

How can an automated script be setup to run at a later time in the day. cron runs recurring tasks. I am interested in a one time process. I want to back up a number of files whenever I make changes to an application and ftp for backup purposes. The script to automate the zipping of files has... (1 Reply)
Discussion started by: msmkeml
1 Replies

8. UNIX for Advanced & Expert Users

Automated FTP

My requiremnet is to write a FTP script which will ftp a file to a specified ftp url. How can I automate the process usnig the unix cron. (11 Replies)
Discussion started by: shauche
11 Replies

9. UNIX for Dummies Questions & Answers

FTP automated?

If I wanted a machine to put a specific file onto another OS far across the internet via FTP - and I wanted to do it automatically not user intervented, how would I do that? Use the PUT command? The file name and position never changes, it gets overwritten and the system on the other end... (6 Replies)
Discussion started by: n9ninchd
6 Replies
Login or Register to Ask a Question