0

I'm trying to execute some commands from inside gnuplot, but I'm getting error. 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!

1
  • It would help if you show the error. I have no clue what you are actually trying here, seems so much more complicated than needed. Commented Dec 19, 2013 at 16:11

1 Answer 1

1

For every ! a new shell is spawned, so that the variable $OUT is not available in the second call. 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"
Sign up to request clarification or add additional context in comments.

3 Comments

In this case I didn't escape $ so command was completely useless.
And if you escape the $ it works? Would surprise me.
I completely remade structure of this code, writing data to adbmon.log in different process. But thank you for your help I will keep in mind next time I use gnuplot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.