Sapphiron Posted November 26, 2004 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 Link to comment Share on other sites More sharing options...
thinkliberty Posted November 28, 2004 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 Link to comment Share on other sites More sharing options...
Michel Posted November 28, 2004 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 Link to comment Share on other sites More sharing options...
Apoc Posted December 3, 2004 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now