Last active
September 22, 2023 04:06
-
-
Save marxspawn/c0926899cdb1a9b51a3951f7b3385e2f to your computer and use it in GitHub Desktop.
SCP SSH Bash script to place to/from files in correct folder
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 | |
###################################################################### | |
##### SSH Bash Script to send/recieve files ##### | |
##### Created By: Raymond Anderson ##### | |
###################################################################### | |
clear | |
echo " | |
------------------------------------ | |
- Choose Option Number from Menu: | |
1. Send File SSH | |
2. Get File SSH | |
3. Exit | |
------------------------------------ | |
" | |
read -p "Choose Option 1, 2, or 3 ---> " | |
if [[ $REPLY =~ ^[1-3]$ ]]; then | |
if [[ $REPLY == 1 ]]; then | |
clear ; echo '' ; echo " - Enter the location of the file/to/send: " | |
echo '' ; read "fileFromLocation" | |
echo '' ; echo " - Enter the location of where to/send/file: " | |
echo '' ; read "fileToLocation" | |
echo '' ; echo " - Enter the name of host pc: " | |
echo '' ; read "hostName" | |
echo '' ; echo " - Enter the address to host pc: " | |
echo '' ; read "hostPC" | |
echo '' ; echo "scp $fileFromLocation $hostName@$hostPC:$fileToLocation" | |
echo '' ; scp $fileFromLocation $hostName@$hostPC:$fileToLocation | |
sleep 2 | |
exit | |
fi | |
if [[ $REPLY == 2 ]]; then | |
clear ; echo '' ; echo " - Enter the location of the file/to/get: " | |
echo '' ; read "fileFromLocation" | |
echo '' ; echo " - Enter the location of where to/put/file: " | |
echo '' ; read "fileToLocation" | |
echo '' ; echo " - Enter the name of host pc where the file is located: " | |
echo '' ; read "hostName" | |
echo '' ; echo " - Enter the address to host pc: " | |
echo '' ; read "hostPC" | |
echo '' ; echo "scp $hostName@$hostPC:$fileFromLocation $fileToLocation" | |
echo '' ; scp $hostName@$hostPC:$fileFromLocation $fileToLocation | |
sleep 2 | |
exit | |
fi | |
if [[ $REPLY == 3 ]]; then | |
clear ; echo " - PC $HOSTNAME Will now exit... " | |
uptime ; sleep 2 | |
exit | |
fi | |
else | |
echo " - Option not available" ; sleep 1 | |
echo " - 1 - 2 - 3 -" | |
exit | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SSH Bash script to aid with sending and receiving files from Mac OS X Terminal on local network using SCP command
The script process will ask a few simple questions