Sapphiron Posted November 26, 2004 Report Share Posted November 26, 2004 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 Thanks in advance Quote Link to comment Share on other sites More sharing options...
thinkliberty Posted November 28, 2004 Report Share Posted November 28, 2004 (edited) 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 November 28, 2004 by thinkliberty Quote Link to comment Share on other sites More sharing options...
Michel Posted November 28, 2004 Report Share Posted November 28, 2004 (edited) 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 November 28, 2004 by Michel Quote Link to comment Share on other sites More sharing options...
Apoc Posted December 3, 2004 Report Share Posted December 3, 2004 #!/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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.