i wanting write script can use grep process on remote server, on each server there user account can ssh out password, idea script will
- sudo passwordless user account
- ssh remote server
- run commands (ps -ef | grep processname)
- display output on local server
- close ssh connection
- exit out of passwordless user account
at minute have:
if [ $1 = -r ] su - useraccount ssh $2 "ps -ef | grep process | grep -v grep" exit else ps -ef | grep process | grep -v grep fi the idea here can run script locally if dont have -r option run locally have
script.sh processname or remotely
script.sh -r remotehost processname i have grep -v grep in there becasue annoys me seeing own grep command in list,
think looks bit cleaner
ideas?
instead of saying
ssh -t host command $argument ... say
argument="-abc" command="'command $argument'" and offer
sst -t host $command the remote machine going have no idea $argument is, sure interpolate string on local machine before sending it. note need tricky quotes, have, above, because cannot interpolate variables inside single ticks ('').
edit:
i have wonder why insisting on running pipes on remote machine. can not say:
ssh -t host -- ps -ef | grep process_name | grep -v grep that seems me best way this. don't have mess around variable interpolation , and curious ticks.
edit 2:
can not use sudo -s username ssh foo?
Comments
Post a Comment