Anno Siegel wrote:
> On 2007-09-06 14:05:18 +0200, said:
>
> > Anno Siegel wrote:
> >> On 2007-09-06 10:17:09 +0200, said:
> >>
> >>> On Sep 6, 1:06 am, deanjon...@gmail.com wrote:
> >>>> the perl script fails without any errors when the system is booted.
> >>>
> >>> That means NOTHING. How do you know it fails? How do you even know
> >>> it runs? Why would you think it should run on a reboot?
> >>
> >> Well, the subject mentions "... launched from rc scripts" which I take
> >> to mean it is called from one of the /etc/*.rc scripts (or however these
> >> are organized in HPUX).
> >
> > That's correct. There's a start/stop script in /sbin/init.d with the
> > usual links to the rc? directories.
>
> It would have been a good idea to mention that explicitly in the body of
> your posting. "Launched from rc" is not part of any standard terminology.
I would have expected any experience Unix person to know what an rc
script is and the related terminology, but no matter.
> > That script works correctly when
> > run interactively.
> >
> >> These scripts run at boot time to set up the
> >> system and thus run at a time when the system is not yet completely set
> >> up. Lots of things can go wrong if something is called too early in the
> >> process.
> >
> > The funny thing is I have another perl script that runs fine when run
> > at boot.
>
> The behavior depends heavily on *when* the script is run during the
> startup process. "Run at boot" is much too unspecific.
OK, run level 3. About one of the last scripts to run.
> > The only difference is that its not listening on a pipe like
> > the problematic one is.
>
> The Perl scripts aren't identical, are they?
Its the same script. The only difference I can see is the fact that
there's no pseudo-tty attached to the processes run from init.d.
> I bet the pipe isn't the only difference. In fact, pipe behavior sounds like a rather unlikely
> candidate.
Yes, I don't think it is. There was one point where I had an explicit
exit in the perl script after it read in a config file (I was printing
the config options back out to ensure it was doing it correctly). The
exit caused the other program on the front of the pipe to die. I then
spent some time trying to work out if it was a SIGPIPE problem (by
sending kill -PIPE signals to that program) to no effect. So the exit
in the perl script must send a different signal back (although I'm not
sure why. I would expect SIGPIPE but HP-UX has some oddities).
> > I wonder if its how I use STDIN. In the problematic script I just do -
> >
> > while (<>)
> > {
> > ...
> > }
> >
> > to read input from the pipe. Should I be using STDIN explicitly
> > instead?
>
> I have no idea. Post the code of the script, the actual call, and
> describe in what stage of startup the call happens.
Its a bit difficult due to commercial obligations (contracts, etc. I'm
sure you're aware of the issues).
Anyway, if you must know, I took an existing perl script found here -
http://www.peppler.org/downloads/scripts (Its the one called
log_watcher.pl.)
and modified it to read from stdin (i.e. a pipe) rather than from a
file location. I also optimised the regexps and cleaned up some of the
logic. It all works fine (at least when I start the scripts
interactively).
> Is perl even part of the HPUX 11 distribution?
I have no idea. 'perl -v' reports -
This is perl, v5.8.0 built for PA-RISC1.1-thread-multi
(with 1 registered patch, see perl -V for more detail)
> Are all modules your script may be using?
I'm not sure what you mean.
> In fact, you might be better off asking in a HPUX-oriented newsgroup.
> The problem may not be specific to perl at all.
I can't find a specific HP-UX group under comp.unix.*. I might try a
generic one later if I still can't solve this.