Operating System - HP-UX
1752587 Members
4535 Online
108788 Solutions
New Discussion

how to get the script file

 
pardeep3dec
Occasional Advisor

how to get the script file

Whenever i am login/switching user it is executing a script file. But i have no information l about this file ike file location , file contents etc ?
Suggest me how can get details of dcript file.
1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: how to get the script file

First, identify which shell is configured for the user in question. In HP-UX, the default shell is the POSIX shell, or (/usr)/bin/sh.

Then, read the man page of the shell in question. In HP-UX, the man page sh(1) is an overview of the various system shells, and the actual man page of the POSIX shell is named "sh-posix". In there, you find a description of what happens when that particular shell is started up. Usually this description is under a heading like "Shell invocation", "INVOCATION" or similar.

"man sh-posix" says:

Shell Invocation

If the shell is invoked by an exec*() system call and the first character of argument zero (shell parameter 0) is dash (-), the shell is assumed to be a login shell and commands are read first from /etc/profile, then from either .profile in the current directory or $HOME/.profile if either file exists, and finally from the file named by performing parameter substitution on the value of the environment parameter ENV, if the file exists. If the -s option is not present and an arg is, a path search is performed on the first arg to determine the name of the script to execute. When running sh with arg, the script arg must have read permission and any setuid and setgid settings will be ignored. Commands are read as described below.

In other words, with the POSIX sh shell:

  •  if you are actually logging in, or switching users using "su -", the first script executed will be /etc/profile,
  • then $HOME/.profile if it exists.
  • on login or "su -", your current directory will be the user's home directory. If you somehow invoke the shell using the login shell convention in a non-home directory, then the .profile script in that directory may be executed instead of $HOME/.profile. But this would be an unusual case.
  • If the environment variable $ENV is set and points to an existing file, then that file is executed as a script.

The (/usr)/bin/ksh shell behaves the same as the POSIX sh shell.

The scummy (/usr)/bin/csh shell, on the other hand, executes first /etc/csh.login if you are actually logging in, then $HOME/.login, and finally $HOME/.cshrc. But if you start a sub-shell, it always runs only $HOME/.cshrc and none of the other scripts.

Script files are text files: the system-wide login scripts (/etc/profile and /etc/csh.login) must be readable by anyone. So you can just run a command like

more /etc/profile

to view them.

Per-user login scripts may or may not be readable to other users; they certainly should not be writeable by anyone other than their owner.

The default versions of per-user scripts, that are copied to each user's home directory as the user account is created, are located in /etc/skel/ directory.

MK