Operating System - HP-UX
1835243 Members
2213 Online
110078 Solutions
New Discussion

Re: How to write a special shell menu ?

 
yyghp
Super Advisor

How to write a special shell menu ?

I have a handheld device which can telnet to our Unix/Linux servers to run an application, it has a full functional keyboard with all keys.
I need to force all users who login to the servers via such device to run a shell script right after they login, without prompting the commandline, like this:

************************
1. Run Application
2. Change Password
3. Logout
************************

I need to restrict all users to access only the options above, they should not be able to do anything else except the actions above.
How to prevent them from using "Ctrl + C" or something else to break the shell and going into the Prompt. That is, they don't need to run "ls", "vi"... It's a security approach.
And how to return back to such menu after users exit the application ?

Thanks!
7 REPLIES 7
Amit Agarwal_1
Trusted Contributor

Re: How to write a special shell menu ?

In your shell script you can use 'trap' command to catch all the siganls and disable them.
Amit Agarwal_1
Trusted Contributor

Re: How to write a special shell menu ?

See 'man sh-posix' or 'man ksh' for more detail.
Rick Garland
Honored Contributor

Re: How to write a special shell menu ?

As mentioned, the shell script will have trap functions to keep the users from breaking out.

The shell script could also contain 3 case statements corresponding to each of the 3 options that would be available.

I would make this a part of the user .profile.
Check to connection to see if they are connecting via the handheld and if so, put them in the captive environment.
Patrick Wallek
Honored Contributor

Re: How to write a special shell menu ?

The best way to do this is to make your menu script their default shell in /etc/passwd.

The users password entry might look something like

user1:password:555:444::/home/user1:/usr/local/bin/menu
RAC_1
Honored Contributor

Re: How to write a special shell menu ?

For all those users put a script as a last in the user's .profile file.
In the script put a trap statements.

trap "" 1 2 3 --> ignote trap for signal 1,2 and 3
your code for menus goes here. (user case statements here)
trap 1 2 3 --> trap signals 1,2 and 3 again.

Anil
There is no substitute to HARDWORK
renarios
Trusted Contributor

Re: How to write a special shell menu ?

Hi,
I should create a shell script like below and make that the default shell in the /etc/passwd file

#!/bin/sh
trap '' INT QUIT TERM KILL

while true
do
clear
print " Make your choise:"
print "************************"
print "1. Run Application"
print "2. Change Password"
print "3. Logout"
print "************************"

read choise

case choise in
1)
do this
;;
2)
passwd ${LOGNAME}
;;
3)
logoff
;;
*)
print "choose between 1-3"
;;
esac
done

Cheers,

Renarios
Nothing is more successfull as failure
yyghp
Super Advisor

Re: How to write a special shell menu ?

Finally I use this instead:

stty intr undef;stty stop undef;stty susp undef;stty dsusp undef


Thanks!