Page 1 of 1

hp-ux下cat和echo命令创建文件报cannot create

Posted: Thu Dec 12, 2019 4:35 pm
by Lz-heng
cat > "$outfile" 2>&1 <<-!EndCat
==== START $cmd ====
!EndCat
cmdresult=$(eval "( $cmd )" 2>&1)
rc=$?
#eval "( $cmd )" >> "$outfile" 2>&1 </dev/null
#rc=$?
cmdresult=$(echo "$cmdresult"|grep -v '^$'|grep -v '^\t+$')
echo "$cmdresult">> "$outfile" 2>&1 </dev/null
cat >> "$outfile" 2>&1 <<-!EndCat2
==== EXITED with rc $rc ====
==== END $cmd ====
!EndCat2

上面脚本中的cat和echo 报错 cannot create
执行使用root用户

Re: hp-ux下cat和echo命令创建文件报cannot create

Posted: Wed Jan 08, 2020 12:18 pm
by MUDBOY
看起来是$outfile这个变量没有正确赋值

可以sh -xxx debug 一下看看