Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
My script runs file when run from a command-line but hangs on the open() call when invoked from Java. No Error is printed out and the print on the following line is never called. Any thoughts on why this would stall on opening the syslog file?
no warnings "all"; use strict; use Net::Dev::Tools::Syslog; my $syslog_file = "tail -n 0 -f /var/log/messages |"; # create syslog parsing object ( $syslog_obj, $error ) = Net::Dev::Tools::Syslog->parse( -report => 1, -parseTag => 1, #-dump => './dump2', -debug => 0, -moreTime => 1, -format => 'noHost', ); unless ($syslog_obj) { printf( "sylog object constructor failed: %s\n", $error ); exit(1); } print STDOUT "Reaches here: $syslog_file \n"; open(FH, "$syslog_file" ) || die "ERROR: open failed: $!\n"; print STDOUT "Doesn't reach here\n"; while (<FH>) { #do whatever } close(FH); sleep 1;
The Java call looks something like this:
Runtime rt = Runtime.getRuntime(); Process proc = null; proc = rt.exec("perl myscript.pl");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl won't Open() when called from Java
by Marshall (Canon) on Feb 23, 2012 at 19:02 UTC | |
by Anonymous Monk on Feb 23, 2012 at 19:33 UTC | |
by Anonymous Monk on Feb 23, 2012 at 19:35 UTC | |
by Marshall (Canon) on Feb 23, 2012 at 19:56 UTC | |
by ikegami (Patriarch) on Feb 23, 2012 at 20:22 UTC | |
| |
by JavaFan (Canon) on Feb 23, 2012 at 19:44 UTC | |
by Marshall (Canon) on Feb 23, 2012 at 19:51 UTC | |
|
Re: Perl won't Open() when called from Java
by JavaFan (Canon) on Feb 23, 2012 at 19:42 UTC | |
by Anonymous Monk on Feb 23, 2012 at 19:54 UTC |