Operating System - HP-UX
1754020 Members
7495 Online
108811 Solutions
New Discussion юеВ

/etc/passwd Startup-Program

 
SOLVED
Go to solution
Kong Kian Chay
Regular Advisor

/etc/passwd Startup-Program

Env : HP-UX 10.20, all users using /usr/bin/csh as start-up shell. NON-trusted system.

What is the syntax for the last field of the /etc/passwd (the Startup-Program) such that : it will execute a script e.g. /usr/local/file1.sh, & then specifiy that the User's startup shell is /usr/bin/csh ? The user should be shown the normal CDE Workspc after login.

Must "file1.sh" be a C-Shell script or can it be a POSIX shell script ?
6 REPLIES 6
Patrick Wallek
Honored Contributor

Re: /etc/passwd Startup-Program

What I would be tempted to do is leave the passwd file alone and put the script that you want to be executed in the users .cshrc file. That way you still get the benefit of the .cshrc file being sources and the environment being set up.
James R. Ferguson
Acclaimed Contributor

Re: /etc/passwd Startup-Program

Hi:

Simply execute your script as the last line of your profile (.login) and leave /usr/bin/csh as the user's shell in /etc/passwd. The script you choose should have its shell interpreter specified in the heading, like:

#!usr/bin/sh #...for Posix...

Your script will run and when done, you will drop into the normal shell, in this case, your csh shell.

...JRF...

Jacques Simon
Advisor
Solution

Re: /etc/passwd Startup-Program

I think the "shell" specified in /etc/passwd must be a codefile (compiled program), and cannot be a script. You can just use a little C-program that starts you file1.sh:
main() {
#include

(void) setuid((uid_t) 0);
execlp("file1.sh", "file1.sh", (char *)0
);
}
(if necessary use absolute path to file1.sh)
Jacques
Tommy Palo
Trusted Contributor

Re: /etc/passwd Startup-Program

If you replace /usr/bin/csh in /etc/passwd with /usr/local/file1.sh it could look like:

#!/usr/bin/csh
.
.
/usr/bin/csh
Keep it simple
Bruce Regittko_1
Esteemed Contributor

Re: /etc/passwd Startup-Program

Hi,

The startup file in /etc/passwd can be a script. I would use

exec /usr/bin/csh

as the last line, if you must execute the script first. As has been pointed out, though, it will probably be better to execute the script from the user's .login file.

If you replace /usr/bin/csh with another script in /etc/passwd, you may consider creating/updating /etc/shells or else the user may not be able to access his/her account via ftp.

--Bruce
www.stratech.com/training
Kong Kian Chay
Regular Advisor

Re: /etc/passwd Startup-Program

Thanks for all the suggestions. I will listen to all the expert advice & refrain from playing around with the start-up shell for /etc/passwd.