linux - commands in bash script doesn't work properly -
i have script :
#!/bin/bash ./process-list $1 det=$? echo $det if [ $det -eq 1 ] echo "!!!" ssh -n -f 192.0.2.1 "/usr/local/bin/sshfs -r 192.0.2.2:/home/sth/rootcheck_redhat /home/ossl7/r" rk=$(ssh -n -f 192.0.2.1 'cd /home/s/r/rootcheck-2.4; ./ossec-rootcheck >&2; echo $?' 2>res) if [ $rk -eq 0 ] echo "not!" fi fi exit;
i ssh
system 192.0.2.1
, run sshfs
command on it. actualy want mount directory of system 192.0.2.2
on system 192.0.2.1
, run program (which located in directory) on system 192.0.2.1
. these ssh
, sshfs
commands work properly. when run them manually , output of program ossec-rootcheck
written file res
,but when run script, mount done no output written file res
. guess program ossec-rootcheck
runned don't know why output isn't written! script used work before don't know happend suddenly!
as far understand program, remote machine has stdin>stderr, how local machine ssh being evaluated?
the end ' means on rk= line, 2>res happens locally. (and there no error ssh, remote error, if any, lost when ssh completes.) try >res
whatever ssh prints out, unfortunately including non-errors.
Comments
Post a Comment