Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > What is required for perl scripts to run correct when launched from rc scripts on HPUX 11?

Reply
Thread Tools

What is required for perl scripts to run correct when launched from rc scripts on HPUX 11?

 
 
deanjones7@gmail.com
Guest
Posts: n/a
 
      09-10-2007
Mark Clements wrote:
> wrote:
> > 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. That script works correctly when
> > run interactively.

>
> Add some logging to the script? I'd use Log::Log4perl or one of the
> syslog alternatives.
>
> $logger->info("starting up");
> ...
>
> $logger->debug("processing line number $count");
>
> $logger->info("exiting normally");
>
> ...
>
> and
>
> (assuming you've wrapped the main body of the program in eval {} )
>
> $logger->error("exiting abnormally with error=$@");


I just tried a "set -x" in the shell script that acts as a wrapper to
the real stuff then ran that from cron.

For some strange reason, cron assigns a pty to the process! So I get
gore like this -

ttytype: couldn't open /dev/tty for reading
stty: : Not a typewriter
Not a terminal
logout

At the start even though I do -

if tty -s; then
....
fi

in the .profile of the account this runs under. Ver odd.

Anyway, the rest of the "set -x" output doesn't show anything amiss -
although it appears that POSIX shells start the program on the
receiving end of a pipe before the program on the front of a pipe. Not
really relevant here, just something I didn't know before.

 
Reply With Quote
 
 
 
 
deanjones7@gmail.com
Guest
Posts: n/a
 
      09-10-2007
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.

 
Reply With Quote
 
 
 
 
deanjones7@gmail.com
Guest
Posts: n/a
 
      09-10-2007
Anno Siegel wrote:
> On 2007-09-06 13:59:58 +0200, said:
>
> > use...@DavidFilmer.com wrote:
> >> 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?

> >
> > Because if it was running I would see it with "ps -ef"

>
> Would you?


Yes. If its not showing up under a ps listing but the program on the
front of the pipe is, I think you can safely surmise that the perl
script has died.

> How long does that thing run?


Its a log monitor. It should run as long as the program on the front
of the pipe runs.

> Do you even have
> an interactive process to run ps from when the script is
> supposed to be starting?


I'm not sure what your asking. I can run top, glance or ps. Its a bit
hard to do that when the system is booting, of course.

> > and it would be
> > reporting errors as they come through the pipe.

>
> Reporting to where?


Email for now. See the original. It also pages but I still have to
modify that part for local use.

> And what errors?


Errors that the program on the front of the pipe might report.

> Last thing you were in doubt if the pipe even works.


I was? The pipe works fine. Its the manner of starting the main script
(boot time or interactively) that seems to be the problem. The only
difference there is that there's no pty attached to the processes. I
can't identify anything as being an issue. For now, anyway.

> How can you rely on it to show if the script is started?


I'm not sure what you mean. The pipe is just part of the process in
the calling shell script.

 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      09-10-2007
On 2007-09-10 05:10:45 +0200, said:

> 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.


Perl is not restricted to the Unix world. A Perl expert is no automatically
an "experienced Unix person".

[...]

>>> 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).


You're on your own then. We can't debug code we can't see.

> 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.)


Yes, we "must know" the code you are trying to run to diagnose it.

[...]

Anno

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
On Windows, how do I protect arguments to shell scripts launched with subprocess? arve.knudsen@gmail.com Python 0 02-08-2011 12:34 PM
Replacing binary data containing & using perl in HPUX 11.11 badkmail@gmail.com Perl Misc 5 09-29-2008 06:50 PM
Scripts run using load in "for" loop run out of order Fa Sidd Ruby 12 01-26-2008 12:06 AM
Constant.t fails 240 of 272 tests and recurs.t fails 1 of 25 tests on HPUX using perl 5.8.7 dayo Perl Misc 11 12-16-2005 09:09 PM
Compatibility of perl on different HPUX-Versions Alex F. Perl Misc 2 02-23-2004 12:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57