#! /usr/local/bin/perl # what to do to test this out.... # 1. read in a cnss file ..... # 2. find the amp lines ... # 3. pass this to the mag_code # 4. do something else..... # actually 1. open pipes and fork off the mag_calc # so as with any good test code lets test if I remember any of this pipe(read_1,write_1); # open pipe 1 pipe(read_2,write_2); # open pipe 2 # unbuffer all i/o on the pipes $old_h=select(read_1); $|=1; select(read_2); $|=1; select(write_1); $|=1; select(write_2); $|=1; select($old_h); if ($pid=fork) { #parent (this program) # so close off the read_1 and write_2 # hence wirte to write_1 and get results off read_2 } elsif (defined $pid) { # this is the child so... # close off read_2 and write_1 # redirect stdin to read_1 and stdout to write_2 # then start up the work code $old_h=select(read_1); $|=1; select(write_2); $|=1; select($old_h); close(read_2); close(write_1); close(STDOUT); open(STDOUT,">& write_2"); select(STDOUT); close(STDIN); open(STDIN,"<& read_1"); close(read_1); sleep(1); system("test2.prl"); # for ($i=5000;$i<5020;$i++) { # print "$i\n"; # } # while (<>){ # print "PP$_!!$_"; # print write_2 "$_!!$_"; # print STDERR "EE$_--$_\n"; # } # close (write_2); die "ending child\n"; } $old_h=select(read_2); $|=1; select(write_1); $|=1; select($old_h); close(read_1); close(write_2); for ($i=5000;$i<5200;$i++) { print write_1 "$i\n"; $line=; chop($line); print "OC::$line,,$line\n"; } print "ending this one\n";