Operating System - HP-UX
1748210 Members
2718 Online
108759 Solutions
New Discussion юеВ

Re: Skipping execution of tail of /etc/profile

 
SOLVED
Go to solution
Ralph Grothe
Honored Contributor

Skipping execution of tail of /etc/profile

Hello,

I need a silly hack for /etc/profile on a Solaris box (but it is basic shell fare)

What greatly annoys me is the way the Solaris package manager is messing about with the global profile by cluttering it with ugly PATH and MANPATH additions whenever one does a pkgadd.
Not only is it mocking all attempts of "style" by comming up with its own idea of indentations and comments, it also prepends PATHs with unimportant package targets before login parses more important PATH settings from /etc/default/login.

Thus I thought, probably the easiest way to overcome this while not obstructing later package manager profile violations (viz. appendages), and relieving me from continous profile modifications, would be to drop in a return statement before the autogenerated mess starts, and relocating the PATH and MANPATH stuff in some ordered config file like HP-UX's /etc/MANPATH.

Though the "return" seems to work (in that the rest of the file is disregarded) I do get an irritating "-sh: cannot return when not in function".

Do you have a more sober hack?

Rgds.
Ralph
Madness, thy name is system administration
6 REPLIES 6
Simon Hargrave
Honored Contributor

Re: Skipping execution of tail of /etc/profile

Have you tried "exit 0" instead of "return"?
Ralph Grothe
Honored Contributor

Re: Skipping execution of tail of /etc/profile

Yeah, but it did what I expected,
viz. kicking out anyone who logs in before they see a shell ;-)
Madness, thy name is system administration
Mark Grant
Honored Contributor

Re: Skipping execution of tail of /etc/profile

This might not work for some shells but you could try

"exec $SHELL"

Never preceed any demonstration with anything more predictive than "watch this"
Simon Hargrave
Honored Contributor
Solution

Re: Skipping execution of tail of /etc/profile

Good point ;)

How about: -

/bin/false <
This should pipe the remainder of the text file through /bin/false, which will just do nowt. The fact that there's no EOF token at the end of the file shouldn't matter since it'll just continue until the file closes (ie real end of file).
Ralph Grothe
Honored Contributor

Re: Skipping execution of tail of /etc/profile

Mark,

yes, this works.
But things get a little complicated because root's personal .profile already bears an exec to a bash, which then is expected to source .bash_profile and .bashrc (to get the goodies from Bash scripting, which works when invoked with --login).
You see, I'm a lousy typer and have to rely on path completion, something the ordinary /sbin Bourne shell doesn't offer.
I will have to fumble a bit with the various profiles till I get it where I want it...
Madness, thy name is system administration
Ralph Grothe
Honored Contributor

Re: Skipping execution of tail of /etc/profile

Simon,

brilliant hack!
That's exactly what I've been looking for :-)
Madness, thy name is system administration