login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > Overige > Linux > [Shell] FTP

[Shell] FTP

Auteur: Joost - 24 mei 2009 - 12:03 - Gekeurd door: Richard - Hits: 3425 - Aantal punten: (0 stemmen)




Uitleg
Met dit script kan je bestanden overzetten via FTP.
Het is handig te gebruiken voor een backup systeem, in combinatie met cronjobs en bijvoorbeeld het MySQL Backup Script van Sliphead.
Je kan dan je backup direct overplaatsen op een andere server.

Installatie
Maak een bestand aan genaamd "ftp_transfer.sh".
Vul daar de onderstaande code in, en vervang de variabelen door jouw gewenste waardes.
Sla het bestand op en chmod het naar 0100.
# chmod 0100 ftp_transfer.sh

Uitvoering
Om het script uit te voeren type je vervolgens:
# ./ftp_transfer.sh

Code:
  1. #!/bin/bash
  2. # Script to transfer files over FTP
  3. # Author: < Medieval | sitemasters.be >
  4. # Year: 2009
  5.  
  6.  
  7. ###########################
  8. # These options must be set to yours! #
  9. ###########################
  10.  
  11. # The FTP host
  12. FTP_HOST="192.168.1.1"
  13. # The FTP port
  14. FTP_PORT="21"
  15. # The FTP user
  16. FTP_USER="ftp_user"
  17. # The password from the FTP user
  18. FTP_PASSWORD="ftp_pass"
  19.  
  20. # dir at remote server to put the file in
  21. REMOTE_DIR="/files"
  22.  
  23. # The file which must be transfered
  24. FILE_TO_TRANSFER="file_to_transfer.tar"
  25.  
  26. ################################
  27. # From here you don't have to edit anything! #
  28. ################################
  29.  
  30.  
  31. # The actions
  32. ftp -n $FTP_HOST $FTP_PORT << end
  33. us $FTP_USER $FTP_PASSWORD
  34. cd $REMOTE_DIR
  35. put $FILE_TO_TRANSFER
  36. bye
  37. end

Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Geen reacties (0)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.014s