host b has alias defined
alias command='ps -aef|egrep "a|b"|egrep -v "c|grep|ksh|sshd|ssh|ps |tail|bash|su \-"'
how can call alias box a?
ssh user@b "command"
not work.
in bash
define function:
mycommand() { ps -aef | \ egrep "a|b" | \ egrep -v "c|grep|ksh|sshd|ssh|ps |tail|bash|su -" }
...and tell shell emit source function when generating remote command:
ssh user@b "$(declare -f mycommand); mycommand"
you can similar alias, eww:
# define alias locally alias mycommand='ps -aef|egrep "a|b"|egrep -v "c|grep|ksh|sshd|ssh|ps |tail|bash|su \-"' ssh user@b bash -s <<eof shopt -s expand_aliases # enable aliases on remote shell $(alias -p) # dump aliases remote shell mycommand # invoke desired alias eof
note expand_aliases
shell option: aliases default available only in interactive shells, , shell invoked command line passed argument not interactive.
in ksh
use typeset -f
rather declare -f
list functions:
ssh user@b "$(typeset -f); mycommand"
Comments
Post a Comment