Upload files from directory via FTP


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/bin/sh
  2. # This UNIX shell script FTPs all the files in the input directory to a remote directory
  3. # It uses a UNIX Shell "hear document" to read the commands to the FTP program from the shell file
  4. # You have to use the -n option to the FTP command to disable the prompting for the password
  5. # the quote in front of the ftp user and pass are also necessary to disable reading from stdin
  6. # the prompt must be turned off for the multi-put to not prompt the user
  7. LOCALDIR=mylocaldir
  8. REMOTESERVER=remote.server
  9. REMOTEPATH=/my/remote/path
  10. LOGIN=myloginname
  11. PASSWORD=mypassword
  12.  
  13. cd $LOCALDIR
  14. ftp -n $REMOTESERVER <<INPUT_END
  15. quote user $LOGIN
  16. quote pass $PASSWORD
  17. cd $REMOTEPATH
  18. prompt off
  19. mput *.*
  20. exit
  21. INPUT_END

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.