2

Hy guys! I have problems with writing bash script to run 50 times my script which generates data files and then plot it to file. I wrote smth like this, but it doesnt work

#!/bin/bash
for i in {1..50}
do
    ./ampl ampltst1 # generates different res.txt file each time
    /usr/bin/gnuplot <<\__EOF
    set xrange [-2:2]
    set yrange [-2:2]
    set term png
    set output "image-${i}.png"
    plot "res.txt" u 1:2 w lines, "res.txt" u 3:4 w lines, "res.txt" u 5:6 w li$
    pause -1
    __EOF
done

Please help me to fix this script!

2
  • How does it not work? Do you get an error message? Other observations. Commented May 13, 2013 at 11:30
  • why pause -1? it requires you to press Enter 50 times. Commented May 20, 2013 at 13:11

1 Answer 1

3

Possibly you have problems with indentation: __EOF must be without any leading spaces:

...
    /usr/bin/gnuplot <<\__EOF
    set xrange [-2:2]
    ...
__EOF
done

Also \ symbol is not required.

Also content of HERE-IS-DOCUMENT will be indented. Is that OK for gnuplot?

If no, you must remove indentation:

for i in {1..50}
do
    ./ampl ampltst1 # generates different res.txt file each time
    /usr/bin/gnuplot <<__EOF
set xrange [-2:2]
set yrange [-2:2]
set term png
set output "image-${i}.png"
plot "res.txt" u 1:2 w lines, "res.txt" u 3:4 w lines, "res.txt" u 5:6 w li$
pause -1
__EOF
done
Sign up to request clarification or add additional context in comments.

Comments

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.