My script from source server trying ssh onto multiple servers and run the application specific command which i can say, other than Operating system commands (like cat, chmod..), i get the error like command: not found. Below is the script.

for host in $(cat hosts_list.txt)
ssh $host chk_auto_up > "cmd_output.txt"

Can anyone assist, what i have to include in the script to identify the command and run and write the output ot the file ?

I have error saying that command not found

  • Is the OS command an alias or in a non-standard path? – cerberus Apr 12 '17 at 4:19

you just edit the line:

ssh $host /path/of/chk_auto_up > "cmd_output.txt"

Define the absolute path of the command.


I found an answer that how to run external command over ssh remotely.

for host in $(cat /***/thishost/**/username/hosts_list.txt)
ssh "$host"
. /**/***/*****/*****/******.${HOST}  
chk_auto_up >> "/****/thishost/***/*****/cmd_output.txt"


  1. hosts_list.txt --> I have list of servers to login by ssh
  2. ssh "$host" --> ssh login happens on the first server.
  3. . /**/***/*****/*****/******.${HOST} --> external command binary path is available here
  4. chk_auto_up >> "/****/thishost/***/*****/cmd_output.txt" --> Run the command and writes the output to source server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.