Help with ftp script

Help with ftp script

Post by Peet Groble » Tue, 02 May 2000 04:00:00



I need to write an FTP script that will fetch files. The both machines
running linux.

How would you go about doing that? I tried a bit, but couldn't get it to
work. It would be fine putting the userid and password in the script, since
this job should run (via cron) every morning.

Please help or point me in the right direction. I know how to do it, using
the plain ftp program. Just the script bothering!

 
 
 

Help with ftp script

Post by thci.. » Tue, 02 May 2000 04:00:00


The way that I have written ftp scripts in the past is with the
following format.  I write a function that creates a separate ftp
script (e.g. makeFTP). Then I call that script once it has been
generated.  See the example below:

makeFTP()
{
  echo "ftp -in << END" > ftpfile
  echo "verbose on" >> ftpfile
  echo "open <servername> >> ftpfile
  echo "binary" >> ftpfile
  echo "user $user $passwd" >> ftpfile
  echo "cd $sourcedirectory" >> ftpfile
  ....  #other ftp commands also redirected to ftpfile
  echo "bye" >> ftpfile
  echo "END" >> ftpfile
  chmod 775 ftpfile

Quote:}

Then with in your script you can call
ftpfile to perform the ftp for you.  I also
suggest redirecting it to an output file so
you can see that the execution worked correctly.
E.G -- ftpfile > file.out

Hope this helps.

Tabitha



Quote:> I need to write an FTP script that will fetch files. The both machines
> running linux.

> How would you go about doing that? I tried a bit, but couldn't get it
to
> work. It would be fine putting the userid and password in the script,
since
> this job should run (via cron) every morning.

> Please help or point me in the right direction. I know how to do it,
using
> the plain ftp program. Just the script bothering!

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Help with ftp script

Post by L.Ra » Tue, 02 May 2000 04:00:00


The .netrc file will allow you to automate your ftp tasks.  Look at
your man pages for netrc (man netrc).  If you need more help after
consulting your man pages, post here and I'll try to find an example.



Quote:>I need to write an FTP script that will fetch files. The both machines
>running linux.

>How would you go about doing that? I tried a bit, but couldn't get it to
>work. It would be fine putting the userid and password in the script, since
>this job should run (via cron) every morning.

>Please help or point me in the right direction. I know how to do it, using
>the plain ftp program. Just the script bothering!

 
 
 

Help with ftp script

Post by Peet Groble » Wed, 03 May 2000 04:00:00


okay, my problem was with the line user $user $passwd. I thought you had to
echo each one on a separate line.
Thanks,
Peet

>The way that I have written ftp scripts in the past is with the
>following format.  I write a function that creates a separate ftp
>script (e.g. makeFTP). Then I call that script once it has been
>generated.  See the example below:

>makeFTP()
>{
>  echo "ftp -in << END" > ftpfile
>  echo "verbose on" >> ftpfile
>  echo "open <servername> >> ftpfile
>  echo "binary" >> ftpfile
>  echo "user $user $passwd" >> ftpfile
>  echo "cd $sourcedirectory" >> ftpfile
>  ....  #other ftp commands also redirected to ftpfile
>  echo "bye" >> ftpfile
>  echo "END" >> ftpfile
>  chmod 775 ftpfile
>}

>Then with in your script you can call
>ftpfile to perform the ftp for you.  I also
>suggest redirecting it to an output file so
>you can see that the execution worked correctly.
>E.G -- ftpfile > file.out

>Hope this helps.

>Tabitha



>> I need to write an FTP script that will fetch files. The both machines
>> running linux.

>> How would you go about doing that? I tried a bit, but couldn't get it
>to
>> work. It would be fine putting the userid and password in the script,
>since
>> this job should run (via cron) every morning.

>> Please help or point me in the right direction. I know how to do it,
>using
>> the plain ftp program. Just the script bothering!

>Sent via Deja.com http://www.deja.com/
>Before you buy.

 
 
 

Help with ftp script

Post by p.. » Tue, 30 May 2000 04:00:00


you can try this to transfer :

#!/bin/ksh
# Script to ftp files to ftp server.

ftp -n <ip-adress> <<!EOF
user <user> <passwd>
put <file>
!EOF

this wil transfer <file> from <ip-adress> as <user> with password <password>

Greets.


> I need to write an FTP script that will fetch files. The both machines
> running linux.

> How would you go about doing that? I tried a bit, but couldn't get it to
> work. It would be fine putting the userid and password in the script, since
> this job should run (via cron) every morning.

> Please help or point me in the right direction. I know how to do it, using
> the plain ftp program. Just the script bothering!

 
 
 

1. help with ftp script

Hi,

I am trying to automate the sending of a file from  aix to  mvs using the
site command . This all works when entering the commands from the command
line but when the comands are put in a script ftp is not picking up the
remote filename properly. The script is as follows
ftp -n $1
user $2 $3
quote SITE LRECL=521
put $4 $5 (replace
quit

the parameters passsed to the file are like  aaaa(hostname) bbbb(user)
ccc(password) ddd(localfile) "'gggfg'"(remotefile)

The remote file needs the single quotes wrapped by the double uotes but the
rogram failes saying invalid dataset name "gggfg". I think it is getting the
parameters mixed up but not sure how to fix. Any help or hints on this
appreciated.

2. dial-in modem setup trouble

3. Help with FTP script!

4. PovLab in dosemu

5. Need help on FTP script writing

6. pcnfs won't let me write

7. Help with ftp script

8. Network Neighborhood for Linux

9. Help with FTP Scripting Please

10. Help with FTP script

11. Please help with ftp script for cron

12. Scripting FTP tasks - How to use FTP in bash scripts

13. Encrypting ftp password in ftp batch script???