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


In reply to Re^4: fork spawn write background problem by grasshopper!!!
in thread fork spawn write background problem by grasshopper!!!

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.