无法从gnuplot执行shell命令

时间:2013-12-19 09:22:09

标签: shell gnuplot

我正在尝试从gnuplot内部执行一些命令,但是我收到了错误。 据我了解,我应该使用“!”在命令之前。 这是我的剧本:

echo "
set terminal dumb 
!OUT=$(adb shell dumpsys meminfo $PID | grep TOTAL )
!OUT=$(echo $OUT | sed -r 's/ +/ /g' | cut -d ' ' -f 2-)
!echo $OUT >> adbmon.log
plot  'adbmon.log' using 1:6 title 'Free'
" > sample.gp && gnuplot sample.gp

我做错了什么? 谢谢你的时间!

1 个答案:

答案 0 :(得分:1)

对于每个!生成一个新shell,以便在第二次调用中变量$OUT不可用。您还可以按如下方式即时绘制所有内容:

gnuplot -persist -e "set terminal dumb; plot '< adb shell dumpsys meminfo $PID | grep TOTAL | sed -r ''s/ +/ /g'' | cut -d '' '' -f 2-' using 1:6"
相关问题