How about this script: #!/bin/csh tool.pl < /dev/null | filter
Duane > On May 2, 2017, at 11:13 AM, Greg London <[email protected]> wrote: > > So, IT got back to me. > Actually, they were pretty quick this time. > some of my tickets take weeks or months. > > The tool has a thing where if you hit control-c > it gives you a tool prompt, at which point the control-D makes it > exit the tool prompt and return to the unix prompt. > But the tool is run inside a csh script and something about the > way csh works, I don't see the tool prompt when its run inside > a shell script unless I also pipe inside the shell script. > > So, if the shell script is just calling "tool.exe", > then control-c skips the tool prompt and returns you to the unix prompt. > But once the shell script calls "tool.exe | filter.pl", then > hitting control-C brings up the tool prompt and it hangs. > > Here's a dummy version of the tool: > #!/opt/perl_5.8.8/bin/perl > $|=1; > $SIG{'INT'} = sub { > print "tool prompt\n"; > my $input=<STDIN>; > exit; > }; > my $cnt=0; > while($cnt++<20){ > print "$cnt\n"; > sleep 2; > } > > Here's the filter: > #!/opt/perl_5.8.8/bin/perl > $|=1; > while(<>){ > print "filtered: $_"; > } > > here's the shell.csh script: > #!/bin/csh > tool.pl | filter.pl > > > > > If I run it from the command line: >> tool.pl | filter.pl > I let it run a bit, then hit control-C, it hangs until I hit control-D. > > > If I run the shell script: >> shell.csh > every time I hit control-C, it exits immediately. > it skips over the tool prompt. > > > So, right there is different behavior between command line and shell > even with the exact same commands. > And then the real tool is even wonkier, isn't perl, so even > more inconsistencies. > > The simple fix is to pass an option to the tool to tell it to skip the > tool prompt when it gets a control c and exit immediately. > Luckily the tool has an option to do this. > > But the good news is I can use my perl filter now. > > Greg > > _______________________________________________ > Boston-pm mailing list > [email protected] > http://mail.pm.org/mailman/listinfo/boston-pm Duane Bronson [email protected] <mailto:[email protected]> http://www.nerdlogic.com/ <http://www.nerdlogic.com/> 5 Goden St. Belmont, MA 02478 617.515.2909 _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

