When I run a C program in this bash script it returns the error.
ssh -n -f *.*.*.* "cd /home/sth/remote && echo "$1" && det=$(./ossec-rootcheck)">/home/sthh/res
Error:
./ossec-rootcheck: No such file or directory
I want to ssh to a remote machine and then run a program on it. I know that this file is located in that path because when I edit it as you see, it works.
ssh -n -f *.*.*.* "cd /home/sth/remote && echo "$1" && ./ossec-rootcheck">/home/sthh/res
and as it echo $1 I can see that it does cd /home/sth/remote right. But I want the return value of that program to be stored in a variable,for example det.
det=$(./ossec-rootcheck)before it does thecdbecause it is evaluating the shell parameters in the expression before it executes it. Why do you need the result indet?detequals 1 rest of script would do something.det=\$(./ossec-rootcheck)so that the command runs on the remote machine.stdout.