linux - how to execute ssh comand on .sh file? -
i trying create .sh file execute things "pwd" or "ls" command. problem when execute .sh file. seems not recognize tasks tried use echo example : echo 'lsapps'
or echo "lsapps"
prints name of task instead execute comand
for example want execute .ssh file makes pwd
var_1=pwd echo $var_1
but prints me pwd instead current path ... idea?
echo
used print on screen (man page reference). if echo 'isapps'
take string , print it. if want execute command can doing isapps
(acutes not quotes, acute below escape key). execute command , show output on screen. if want store output of command in variable, can
<variable_name>=`isapps`
this store output in variable. note there no space between variable name , command. also, not quotes instead acutes. print variable on screen can use echo doing echo $<variable_name>
if don't want see output @ all. can do
isapps > /dev/null
this execute command not see stdout on screen.
as far ssh concerned, ssh-keygen
, ssh-copy-id user@remote_ip
set ssh keys don't have enter password ssh. once have done that, can use ssh user@remote_ip
in shell script.
Comments
Post a Comment