Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

(WAY OT) Setting up a user's profile

by RedDog (Pilgrim)
on Oct 01, 2001 at 17:55 UTC ( [id://115868]=perlquestion: print w/replies, xml ) Need Help??

RedDog has asked for the wisdom of the Perl Monks concerning the following question:

I know this isn't Perl related, but I am quite stumped. I am trying to edit the .profile of a user so that all they can run is a single program at login, and if they try to use Ctrl-C or Ctrl-Z to exit, the system would ignore it, and when they do exit the program properly, they would be logged off the system. Right now, if they log off properly, they get a command prompt (they also get a prompt if they do a Ctrl-C or Ctrl-Z).
if [ "$TERM"="" ]then eval `tset -s -Q -m':?hp'` else eval `tset -s -Q` fi stty erase "^H" kill "^U" intr"^C" eof "^D" stty hupcl ixon ixoff tabs PATH=$PATH:. set -u trap "echo 'logout'" 0 set -o ignoreeof EDITOR=vi export EDITOR ## Here are the lines that I am adding. cd /home/production/scripts USER=`who am i|cut -c 1..8` (trap "trap 0;exit" 0 1 3 15; cobrun /home/production/cobol/obj/eftchg + $USER)
The system in question is an HP-UX mainframe system, and the user's shell is ksh by default. If there are any monks out there who have a good understanding of shell scripting, any help or ideas would be greatly appreciated. Thank you.
RedDog

Replies are listed 'Best First'.
Re: (WAY OT) Setting up a user's profile
by MZSanford (Curate) on Oct 01, 2001 at 18:15 UTC
    I have done this before, and have the following to say :
    is it ksh ? (as you said): If this is Korn Shell, read up on the trap command.

    can you change the /etc/passwd: You can change the shell in the /etc/passwd to be the program in question. Then killing it, or exiting it in any way would kill the session.

    Or, lastly, i would suggest catching the signals using the %SIG hash within the perl program this is for (or whatever catch mechanisim if it is not perl)
    "They shall not overcome. Whoever told them that the truth shall set them free was obviously and grossly unfamiliar with federal law."
        -- John Ashcroft
      I wasn't able to change the shell to the name of the program in the /etc/passwd file(although I do have root access to the system), but I now give you the following lines which solved my problem:
      USER=`who am i|cut -c 1-8` trap 'trap 0;exit' 0 1 3 15 cobrun /home/production/cobolobj/eftchg $USER wait exit
      Your reference to the trap command got me looking in the right direction. Thanks again for your help.

      RedDog
Re: (WAY OT) Setting up a user's profile
by thatguy (Parson) on Oct 01, 2001 at 20:48 UTC
    you could always change their shell from /bin/ksh (or whatever) to that of the program. I did this for my sister so all she could run was a irc.

    prolly best to use sam to do it. the program may need to be in /etc/shells as well, but YMMV
    -p

Re: (WAY OT) Setting up a user's profile
by mischief (Hermit) on Oct 02, 2001 at 18:34 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://115868]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-16 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found