I'm a newbie: need to script "init S", then continue running code

K

Kafer

Hi all,

I am very new to Perl, so please bear with my lack of experience here. I am
in the process of writing a couple of short Perl scripts to handle some
automated backup procedures to be shipped to some of our customer sites. We
are running Solaris 8 / SPARC, and would like our script to change from
runlevel 3 to runlevel S before executing any code, effectively we want to
issue an "init S" (prompting for root password is ok), then execute our
code.

I can do the init S bit via:

exec init => 'S';

.... but of course the script effectively dies at that point. Any ideas? I
don't mind reading if someone knows a how-to or good cookbook site.


Thanks in advance.
 
J

Jeff 'japhy' Pinyan

[posted & mailed]

I can do the init S bit via:

exec init => 'S';

... but of course the script effectively dies at that point. Any ideas? I
don't mind reading if someone knows a how-to or good cookbook site.

That's what exec() DOES. It replaces the current process with the one you
give it. It says "stop running me, and run THIS program instead". You
either want to use system(), which runs the program you tell it to and
THEN returns to the Perl program, or a fork-exec combination.
 
D

Darren Dunham

Kafer said:
I am very new to Perl, so please bear with my lack of experience here. I am
in the process of writing a couple of short Perl scripts to handle some
automated backup procedures to be shipped to some of our customer sites. We
are running Solaris 8 / SPARC, and would like our script to change from
runlevel 3 to runlevel S before executing any code, effectively we want to
issue an "init S" (prompting for root password is ok), then execute our
code.

Ouch. I can think of *no* reason you would ever want to do an 'init S'
on Solaris. 'init 1', maybe.
I can do the init S bit via:
exec init => 'S';

*boggle*. You know, I suppose that works just fine, but I would never
write it that way. Why have you used the '=>' operator there?
... but of course the script effectively dies at that point. Any ideas? I
don't mind reading if someone knows a how-to or good cookbook site.

I suggest you read the documentation that comes with perl first.

% perldoc -f exec
exec LIST
exec PROGRAM LIST
The "exec" function executes a system command and
never returns-- use "system" instead of "exec" if
you want it to return.
 
K

Kafer

We do an init S to settle down the filesystem before doing a backup via
ufsdump. This script is intended to check the stability of a DiskSuite
mirrored array, bring the system down to init S, detach the array, then dump
the secondary slice. From what I've been reading, it looks like exec will
get me through init S, but what about code after init S?

I was toying with the idea of a one-time rc script to pickup in init S where
init 3 left off, but I hate having scripts lying around that may not get
cleaned up properly in the event of a problem, especially when it could
impact a filesystem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top