Created
April 15, 2016 16:16
-
-
Save BackFront/38ae2b4b4736dd86528a6094774e01a3 to your computer and use it in GitHub Desktop.
Script auxilio para envio entre local para servidor linux
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/bash | |
### Set Language | |
### Set default parameters | |
if [ "$(whoami)" != 'root' ]; then | |
echo $"You have no permission to run $0 as non-root user. Use sudo" | |
exit 1; | |
fi | |
pacote=$(dpkg --get-selections | grep "^expect" ) | |
if [ -n "$pacote" ] ; | |
then echo | |
echo "Start..." | |
else echo | |
echo "'sshpass' packege is necessery." | |
echo "install Expect? (Y/N)" | |
read install_pack | |
case $install_pack in | |
"Y") | |
sudo apt-get install expect | |
;; | |
"N") | |
exit | |
;; | |
esac | |
fi | |
echo "===================================================================" | |
echo "========================== Automatic SCP ==========================" | |
echo "===================================================================" | |
echo "* Powered by: Douglas Alves <alves.douglaz@gmail.com>" | |
echo "* Version: 1.0" | |
echo "_________________" | |
echo "Select an option:" | |
echo | |
echo | |
echo | |
echo | |
echo "[0] - Sendfile: host => local" | |
echo "[1] - Sendfile: local => host" | |
echo "------------------------------------------------------------------" | |
echo | |
echo | |
echo | |
echo | |
read option; | |
case $option in | |
0) | |
set timeout 60 | |
echo "SSH user:" | |
read ssh_user; | |
echo "" | |
echo "SSH password:" | |
# stty -echo | |
# read ssh_password; | |
# stty echo | |
echo "" | |
echo "SSH host:" | |
read ssh_host; | |
echo "" | |
echo "SSH port (NULL to use default):" | |
read ssh_port; | |
echo "" | |
echo "SSH path/file:" | |
read ssh_path; | |
echo "" | |
echo "Local path/file:" | |
read local_path; | |
R1="$ssh_user@$ssh_host" | |
scp -P $ssh_port -r $local_path $R1:$ssh_path | |
expect "$ssh_user@$ssh_host's password:" | |
send "" | |
;; | |
1) | |
echo "SSH user:" | |
read ssh_user; | |
echo "" | |
# echo "SSH password:" | |
# stty -echo | |
# read ssh_password; | |
stty echo | |
echo "" | |
echo "SSH host:" | |
read ssh_host; | |
echo "" | |
echo "SSH port (NULL to use default):" | |
read ssh_port; | |
echo "" | |
echo "SSH path/file:" | |
read ssh_path; | |
echo "" | |
echo "Local path/file:" | |
read local_path; | |
R1="$ssh_user@$ssh_host" | |
scp -P $ssh_port -r $local_path $R1:$ssh_path | |
expect "$ssh_user@$ssh_host's password:" | |
send "" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment