SCP and Pass Variable in Bash Script

#!/bin/bash
read -p 'Enter the Files to be Send to Remote Host: ' files
destination_directory='/home/oracle'
scp -i /Users/shadab/wha.pem $files oracle@192.168.1.200:$destination_directory
## SAMPLE USAGE ##
# shadabs-MacBook-Pro:~ shadab$ ./scp_files.sh
#Enter the Files to be Send to Remote Host: *.sh
#scp_files.sh                                  100%  344    39.1KB/s   00:00
#scp_files_gone.sh                             100%  344    52.3KB/s   00:00
#
#
#shadabs-MacBook-Pro:~ shadab$ ./scp_files.sh
#Enter the Files to be Send to Remote Host: scp_files.sh
#scp_files.sh                                  100%  434    80.5KB/s   00:00

You can now add alias for this script in .bashrpc file
alias scpo=’sh /Users/shadab/scp_files.sh’

Category: BashLinuxLinuxScript

Tags:

Leave a Reply

Article by: Shadab Mohammad