in reply to Re: fork spawn write background problem
in thread fork spawn write background problem

Thank's for your answer but the pause 30 reread replot line's should make gnuplot update automatically.If I put the data in a separate file, say run.gp.And change the child section to code

exec("gnuplot /home/philip/Desktop/PERLBITCOIN/run.gp"); exit;

It will run gnuplot and it updates.Gnuplot will not reread and replot if I use the data section instead of the separate file.This is just for interests sake, is there some sort of block on the gnuplot process by using open rather than by exec.

Replies are listed 'Best First'.
Re^3: fork spawn write background problem
by GotToBTru (Prior) on Oct 29, 2015 at 15:22 UTC

    According to what I read, the reread command is supposed to work with input from STDIN which is what you're using. Could be a gnuplot issue instead of a Perl issue.

    Dum Spiro Spero

      Tried another direction and this works.

      #!/usr/bin/perl -w use LWP::Simple; use Fcntl qw(:DEFAULT :flock); my $interval = 60; # seconds between calls my $url='http://www.cryptonator.com/api/ticker/btc-gbp'; my $gpdata; $SIG{TERM}=sub{close(PIPE);if(defined(*OUT)){close(OUT);print "done\n" +;exit;}}; sub init{ local $/=undef; $gpdata=<DATA>; open PIPE, "|gnuplot -persist -geometry 512x384+0+0" || die "Can't + initialize gnuplot\n"; select((select(PIPE), $| = 1)[0]); } sub fetch{ my $replie = get($url); print"$replie \n"; my($a,$b,$c,$d)= $replie =~ /^.+?(\d+\.\d+).+?(\d+\.*\d*).+?(\d+\ +.\d+).+?(\d+).*$/; $a="not defined" unless defined($a); $b="not defined" unless defined($b); $c="not defined" unless defined($c); $d="not defined" unless defined($d); open(OUT,">>","/home/philip/Desktop/PERLBITCOIN/TICKER/bitgbpZ.dat +") or die "BIT File open error $!\n"; print OUT "$d,$a,$c,$b\n"; close(OUT); } sub update{ print PIPE $gpdata; } sub loop{ fetch(); sleep 1; update(); } sub main{ init(); do{ loop; sleep 60; }while(1) } main; __DATA__ reset set terminal 'wxt' delta_v(x) = ( vD = x - old_v, old_v = x, vD) old_v = NaN unset key set xtics border in scale 0,0 nomirror rotate by -90 offset character + 0,0 autojustify set datafile separator ',' set bmargin at screen 0.2 set palette defined (-1 "red", 1 "#1B6821") set cbrange [-1:1] set grid set yrange [*:*] unset colorbox set style fill solid noborder #set xrange [1446160802-946684800:1446160902-946684800] set xdata time set timefmt "%s" set xtics 60 set format x "%H:%M:%S" # or whatever set xlabel "time" #set xtics autofreq data=system("tail -n 1 /home/philip/Desktop/PERLBITCOIN/TICKER/bitgbpZ +.dat | cut -d ',' -f2") set title data plot '< tail -n 60 /home/philip/Desktop/PERLBITCOIN/TICKER/bitgbpZ.dat +' using 1:($2):((delta_v($2) > 0.0) ? 1 : -1 ) title data with lines +p lt 6 lw 2 palette

      Thanks to all for help and suggestions