fixed ssh func bug where remote command was before host
this fixed issue with remote script modulemaster
parent
c857bb50be
commit
3ffbd545fe
|
@ -177,7 +177,7 @@ EOF
|
|||
# sshcp -y -d $host $bscript $rscript -- "${sshargs[@]}"
|
||||
# return
|
||||
if sshcp -d $host $bscript $rscript -- "${sshargs[@]}"; then
|
||||
# make remote script excuteable
|
||||
# echo make remote script excuteable
|
||||
ssh "${sshargs[@]}" "$host" "chmod +x $rscript"
|
||||
ssh "${sshargs[@]}" "$host" "$usesudo" "$env_vars" "$shell" $login "$rscript" "$(escape_args "$@")"
|
||||
# now delete it, save script if passed an explicit name
|
||||
|
|
|
@ -81,7 +81,6 @@ sshpubkey () {
|
|||
usage: sshpubkey <pubkey opts> host <ssh script options>
|
||||
-a, <alternate user> put the key at another user on remote. if you want to put it to root use 'root' will require remote sudo
|
||||
-u, <user> remote user if not available in host
|
||||
-s, <paswd> sudo password for remote if needed
|
||||
-k, <key> can be either the path to a public key file or the name of the key currently loaded in an ssh agent
|
||||
-l, list the keys for the remote user
|
||||
-r, remove the key from the user, use the comment identifier of the public key
|
||||
|
|
|
@ -30,9 +30,9 @@ ssh() {
|
|||
|
||||
cat <<EOF
|
||||
usage:
|
||||
ssh <script options> host <SSH command options> <commands to run on remote>
|
||||
put any additional SSH (man ssh) options after the host, aborting
|
||||
hH:tu:dF:p:ro:k:
|
||||
ssh <script options> host <commands to run on remote>
|
||||
put any additional SSH (man ssh) options can be added with -s, be sure to quote
|
||||
:hH:tu:dF:p:ro:k:
|
||||
-h
|
||||
-H
|
||||
-t
|
||||
|
@ -41,23 +41,23 @@ hH:tu:dF:p:ro:k:
|
|||
-F
|
||||
-p
|
||||
-r
|
||||
-s
|
||||
-o
|
||||
-k
|
||||
-k-z no
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
|
||||
if [[ $SSH_CONFIG ]]; then
|
||||
[[ ! -f "$SSH_CONFIG" ]] && ssh_config "$SSH_CONFIG"
|
||||
cfg="-F $SSH_CONFIG"
|
||||
fi
|
||||
|
||||
# echo passed: $*
|
||||
|
||||
local OPTION; local OPTARG; local OPTIND
|
||||
while getopts 'hH:th:u:lF:p:ro:k:' OPTION; do
|
||||
# echo processing: option:$OPTION argument:$OPTARG index:$OPTIND remaining:${@:$OPTIND}
|
||||
# echo ssh passed: "$@"
|
||||
debug processing: option:$OPTION argument:$OPTARG index:$OPTIND
|
||||
# echo remaining:${@:$OPTIND}
|
||||
case "$OPTION" in
|
||||
h)
|
||||
help
|
||||
|
@ -86,7 +86,7 @@ EOF
|
|||
opts+=" -o $OPTARG"
|
||||
;;
|
||||
p)
|
||||
# pw=$OPTARG
|
||||
# pw=$OPTARGF
|
||||
#e, f, d
|
||||
case "$OPTARG" in
|
||||
e)
|
||||
|
@ -114,7 +114,7 @@ EOF
|
|||
# mp=true
|
||||
# ;;
|
||||
*)
|
||||
echo unknown script option $OPTARG
|
||||
echo unknown ssh script option $OPTARG xxx
|
||||
help
|
||||
return 3
|
||||
# opts+=" ${@:$OPTIND:1}"
|
||||
|
@ -128,7 +128,8 @@ EOF
|
|||
|
||||
[[ (! $host) && $1 ]] && { host=$1;shift; }
|
||||
|
||||
debug extra ssh options and the remote commands: $@
|
||||
debug remote commands/arguments to pass: $@
|
||||
debug todo parse additional options after --
|
||||
|
||||
[[ ! $host && ! $list ]] && echo host/ip required, aborting && return 2
|
||||
if [[ $host ]]; then
|
||||
|
@ -146,11 +147,11 @@ if [[ $ret ]]; then
|
|||
# return arguments so a command can be composed elsewhere
|
||||
{ echo "$host,$opts $* ,$sshpass"; return 0; }
|
||||
else
|
||||
sshcmd="$sshpass $(which ssh) $term $opts $host"
|
||||
sshcmd="$sshpass $(which ssh) $term $opts $host $*"
|
||||
if [[ $list ]]; then
|
||||
echo $sshcmd
|
||||
echo "$sshcmd"
|
||||
else
|
||||
$sshcmd "$@" || echo SSH Command Failed: $sshcmd "$@"
|
||||
$sshcmd || echo SSH Command Failed: $sshcmd
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue