linux - How to run a bash function() in a remote host? in Ubuntu -
this question has answer here:
- shell script: run function script on ssh 2 answers
i running bash
script, when try run functions on remote machine, says
bash: keyconfig: command not found
here script:
keyconfig() { sed -i.bak -r "/^$1/s/([^']+')([^']+)('.*)/\1$2\3/" $3 } remoteexecution() { ssh ppuser@10.101.5.91 " keyconfig $1 $2 $4 " } remoteexecution
resone error:
when
ssh ppuser@10.101.5.91 " keyconfig $1 $2 $4 "
you trying execute command keyconfig
on remote machine 10.101.5.91
not there:
2 solution problem
1) make script on remotehost contains keyconfig
code same name
or
2) execute following instead of function
ssh ppuser@10.101.5.91 "sed -i.bak -r "/^$1/s/([^']+')([^']+)('.*)/\1$2\3/" $3"
please note may have add few escape depending on sed syntax using
Comments
Post a Comment