Kayan Kayan - 5 months ago 29
Bash Question

Run gnuplot scipts in background within a shell script

I can't run my gnuplot script in background within a shell script. Something like in following example

#!/bin/bash
for i in 1 2 3
do
run gnu_script($i).p
done


As per the answer given by Christoph I could able to do it. But still the figure windows are coming and not letting me to do anything in the computer.

Answer

What about something simple as

for i in 1 2 3
do 
    gnuplot script$i.gp &
done

That assumes, that you have different scripts script1.gp, script2.gp and script3.gp.

If you have only a single script and want to pass the iteration number to it, you could do it with

for i in 1 2 3
do
    gnuplot -e "i=${i}" script.gp &
done

A simple gnuplot script script.gp for testing this is

set terminal pngcairo
set output sprintf('script%d.png', i)
plot x title sprintf('%d', i)
pause 10

The pause 10 makes gnuplot pause for 10 seconds.

Comments