Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want that when certain users login they will have a menu instead of accessing the shell with some options that i will configure. I've seen somewhere a perl script (using ncurses i think) that did this but i didn't saved the link and now i can't seem to find it anymore. Anybody aware of anything like this available?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You can have their shell execute a perl (or any kind of) script upon login by putting it in their ~/.bashrc file. (make sure to put a & at the end of the command if you want the rest of the logon script to finish executing)

What kind of a menu are you wanting to create?

share|improve this answer
    
Just some simple stuff like a menu with: start/stop/restart service X. After a little Google i think I'll write a little bash script to do that using dialog and then replace their shell with this script as they don't need shell access, this menu will be enough. –  daniels Jul 3 '09 at 21:48
1  
Even better - if you do it that way, when they exit the script (or even ctrl-c) they will be logged out. –  Brent Jul 3 '09 at 21:53
1  
Just something to look out for. A lot of apps requires a valid shell in order for the "system" or "exec" command to work in spawning off a start/stop request. So, making the perl script the users "shell" may not work like you think. –  pulcher Jul 3 '09 at 21:55
1  
better if it's .bash_profile, which gets run at login. .bashrc happens for every shell and anything interactive can cause problems –  freiheit Jul 4 '09 at 1:29
add comment

If you want something curses based, check out the linux dialog command (http://linux.die.net/man/1/dialog). You can achieve menu-like functionality using this with little development on your part. It's also pretty much self-contained. As far as I can tell, you only need the dialog binary file, so you don't have to load a bunch of extra software on your machine if you don't want to. Most of the time, I simply write a shell script using the echo command to print out a menu, the read command to read a choice by the user, and a case statement to process the choice and run the task associated with it. Then I call this menu script from the startup file (.profile or .login depending on which shell is used). This isn't fool-proof, but it is quick and dirty.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.