Created
July 28, 2014 12:25
-
-
Save adilsoncarvalho/3c33e1f1220d395399e3 to your computer and use it in GitHub Desktop.
Enviando arquivos para um ftp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
USERNAME="username" | |
PASSWORD="password" | |
SERVER="hostname or ip here" | |
# Directory where file is located | |
DIR="/some/directory" | |
# Filename of backup file to be transfered | |
FILE="filename" | |
# login to ftp server and transfer file | |
cd $DIR | |
ftp -n -i $SERVER <<EOF | |
user $USERNAME $PASSWORD | |
binary | |
mput $FILE | |
quit | |
EOF | |
# End of script | |
If you have curl installed, it also uploads by FTP. | |
I use it to upload regularly to my rented host. | |
(I really like mickwombat's script, though) | |
If you need something that fits onto one line (for example, for use as a .bashrc alias or a cron job), this can be a convenient way to do it. | |
Code: | |
# The next 9 lines are lifted from mickwombat's script | |
#!/bin/sh | |
USERNAME="username" | |
PASSWORD="password" | |
SERVER="hostname or ip here" | |
# Directory where file is located | |
DIR="/some/directory" | |
# Filename of backup file to be transfered | |
FILE="filename" | |
# login to ftp server and transfer file | |
curl -T $FILE -u $USERNAME:$PASSWORD $SERVER/$DIR | |
-T is the Upload flag. | |
-u is the user authentication flag. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment