Jump to content

Remote FTP AAARRRGH!


Recommended Posts

Hi all

 

I use ftp scripts in windows to backup some files on all my linux server.

 

I want to automate these backups on the linux boxes instead of running it on my pc. I want them to "put" the files to a ftp server.

 

My windows ftp scripts work perfectly in windows, the moment I run them in linux, it does not accept the "ftp -s:scriptname hostname" command. I found out that ftp under Mandrake 10 does not support the -s parameter.

 

I have tried piping the script into the command like so: "ftp hostname < scriptname"

The remote server tells me the following: 500 AUTH not understood.

 

Please help , I'm stuck :help:

 

Thanks in advance

Link to comment
Share on other sites

Install c-kermit and use a script like this

 

You can download c-kermit from:.http://www.columbia.edu/kermit/ck80binaries.html

 

#!/usr/bin/kermit +
# script from
# http://www.columbia.edu/kermit/ftpscripts.html

while true {
   ftp open FTP.EXAMPLE.COM /user:<DA USER> /password:<DA PASSWORD>
   if fail exit 1 Can't reach host
   if not \v(ftp_loggedin) exit 1 FTP login failed
   ftp cd <NAME OF DIRECTORY TO UPLOAD FILES>
   if fail exit 1 Directory change failed
   while true {
       ftp put <NAME OF FILE 1>  
       ftp put <NAME OF FILE 2>
       ftp put <NAME OF FILE 3>
       ftp put /recursive <NAME OF DIRECTORY 1>/*
       ftp put /recursive <NAME OF DIRECTORY 2>/*
       if success goto done
       if not \v(ftp_connected) break
   }
   ftp bye  
}
:done
exit

 

Although I would use ssh via scp for uploading files. That way your scripts don't need a password in them and your password is not transmitted via plain text.

Edited by thinkliberty
Link to comment
Share on other sites

For most command in linu there is a manual with extra info about it.

 

for example:

 

man ftp

 

I use lftp myself sometimes (although I prefer sftp or scp), but I don't know if it can be used for automating things.

 

man sftp (ftp using ssh)

man scp (copy using ssh)

 

The bash-completion-package is also nice to install ...

 

Bash-scripting is handy, ofcourse you are free to use what you want(another shell, perl, ...):

 

http://www.tldp.org/LDP/abs/html/

Edited by Michel
Link to comment
Share on other sites

#!/bin/ksh
#This script will take in a value and ftp it from directory to server
if [ $# -lt 2 -o $# -gt 3 ]
       then echo "Usage: ftp_put filename destination [bin]"
       exit 1
fi
echo "
      open 127.0.0.1
      user apoc password
      $3
      put $1 $2
      bye
" > $$
ftp -n < $$
rm $$

 

This is a script i use at work.. it creates a tempory file of the PID with the commands to be sent to the FTP client, and this works for the Korn Shell and the FTP on AIX (not tested at home yet, but this should work for you.

 

name the script anything you like (ftp_put.sh) and then call is as so:

ftp_put.sh filename_to_send destination_dir_filename

 

if you want to specify binarey but bin on the end of the above. in the script alter the server, username and password to yours (could have these in a file or pass them through by altering the script.

 

Apoc

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...