简体   繁体   English

无法从gnuplot执行Shell命令

[英]Can't execute shell commands from gnuplot

I'm trying to execute some commands from inside gnuplot, but I'm getting error. 我正在尝试从gnuplot内部执行一些命令,但出现错误。 As far as I understand I should use "!" 据我了解,我应该使用“!” before command. 在命令之前。 Here is my script: 这是我的脚本:

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

What am I doing wrong? 我究竟做错了什么? Thank you for your time! 感谢您的时间!

For every ! 对于每个! a new shell is spawned, so that the variable $OUT is not available in the second call. 会产生一个新的shell,因此变量$OUT在第二个调用中不可用。 You can also plot everything on-the-fly as follows: 您还可以按如下方式即时绘制所有内容:

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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM