我陷入了困境,
我在node2上运行这个命令
netstat -tlpna|grep `ps aux|grep tnslsnr|grep -v grep|awk '{print $2}'`|head -1
它工作正常并给了我这个输出
tcp 0 0 10.6.1.22:1521 0.0.0.0:* LISTEN 2601/tnslsnr
但是当我从 clinet 机器到 node2 运行此命令时,它给了我错误。
ssh root@$(pcs status|grep oracle_LR|awk '{print $4}') 'netstat -tulpna $(ps aux|grep -v grep|grep tnslsnr'|awk '{print $2})'
关注@steeldiver 后
我在 awk 周围添加了双引号,它正在工作
ssh root@$(pcs status|grep oracle_LR|awk '{print $4}') 'netstat -tulpna|grep $(ps aux|grep tnslsnr|grep -v grep|awk "{print \$2}")'|head -1
给我这个输出
tcp 0 0 xxx.xxx.xxx.xxx:1525 0.0.0.0:*
监听 2601/tnslsnr
但
当我在脚本中添加这一行时。
$echo "<pre>`ssh root@$(pcs status|grep oracle_LR|awk '{print $4}') 'netstat -tulpna|grep $(ps aux|grep tnslsnr|grep -v grep|awk "{print \$2}")'|head -1`</pre>"
当我运行时它给了我这个输出
grep: oracle: No such file or directory
grep: 2601: No such file or directory
grep: 0.0: No such file or directory
grep: 0.0: No such file or directory
grep: 227812: No such file or directory
grep: 18536: No such file or directory
grep: ?: No such file or directory
grep: Ssl: No such file or directory
grep: Aug27: No such file or directory
grep: 6:16: No such file or directory
grep: LISTENER: No such file or directory
我一直在玩这个,但没有任何作用