Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement