?
Solved

How do I log a user completely out of AIX from inside a script?

Posted on 2008-02-06
4
Medium Priority
?
316 Views
Last Modified: 2013-11-17
When the user logs in, the .profile runs a shell script that displays a menu.  If the Quit option is selected, I want the user to be logged completely out of AIX.  The following, which I'm now using, exits to the O/S.  The user must then manually type "exit" to log completely out of AIX.

[Qq ]  ) exit 0;;    # user types "Q" or "q" from the displayed menu
* ) ;;

esac
done
exit 0

I don't want the user to have access to an OS command line prompt at all.  Anyone know how I can log the user out from inside the script?

Thanks!
0
Comment
Question by:monkeybiz12345
4 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 20837913
If this run in .profile, make sure to change the ^C using stty command since user might break the script with ^C (Control-C). Similarly for ^Z. Please see stty man page to see how to do it.

In the *) case, you just put the exit command:

*)
exit
;;
esac
0
 
LVL 48

Accepted Solution

by:
Tintin earned 100 total points
ID: 20838924
In the .profile where the script is invoked, prefix it with exec, eg:

exec /path/to/menu-script

exec overlays the current process (shell) with the command specified.  
0
 
LVL 1

Assisted Solution

by:cloud5
cloud5 earned 100 total points
ID: 20845043
If you wish *any* exit of the script to log out of AIX, change your script execution from this form:

  /path/script

to

  exec /path/script

To prevent the user from being able to press Ctrl-C, Ctrl-\, Ctrl-U, or Ctrl-Z, do this prior to the "exec" (best location is at the very top of the user's .profile or, even better, if *ALL* users should be subject to this, near the top of /etc/profile):

    trap "" 2 3 15 18

(that's two quotation marks)

This tells the shell simply to ignore those four signals, *even if they've been changed to different key sequences elsewhere*.

So, the full sequence is:

    trap "" 2 3 15 18

    ...

    exec /path/script
0
 

Author Closing Comment

by:monkeybiz12345
ID: 31428711
Thanks!  Exactly the info I needed.  Split points because both of you provided great answers to what I can now see was a not quite clear enough question.  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

592 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question