Working script for single host
I sourced the following bash scripts inside .bashrc and is working fine with single hostname host1. I can do scp, rsync and other remote commands without any problem. But I want to use it for multiple hostnames eg. host1, host2, host3.
HPC_HOST=${HPC_HOST:-host1}
lastarg() {
# get the last argument
for last; do true; done; echo $last;
}
hpc() {
HERE="~${PWD#$HOME}"
ssh -t $HPC_HOST "cd $HERE; bash";
}
scp_to_hpc() {
# Usage: scp_to_hpc files
# Purpose: will copy file to crysden:$(pwd)/file
#hpc_mkcwd
HERE="~${PWD#$HOME}"
scp $@ $HPC_HOST:$HERE
}
Current Solution
Currentlty I created three copies of the same script and modified the function names accordingly with respect to host name.
Expected Solution
I expect there must be a way to call the multiple hostname in the above script. and execute the commands with anyhost.( may be we need to define function varaible as well for host name.
I also apreciate the possible ideas to use multiple host in the above bash script.