LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Disable exit (https://www.linuxquestions.org/questions/linux-newbie-8/disable-exit-831277/)

karlochacon 09-09-2010 06:02 PM

Disable exit
 
hi guys

I'm working in a simple script which simulates th shell
basically my customer wants a menu in linux which will be the only access for operators.... and they don't want them to have direct shell access so below is the best I could do... now I am having problems to handle the exit command since I only want end as my exit command

is there a way to do that? using if or something?

Code:

    #!/bin/bash
    while [ "$whichcmd" != end ]
    do
    read whichcmd?"Enter Command: "
    $whichcmd
    done
    whichcmd=0

What I need is someone enters the command exit


thanks a lot

AsusDave 09-09-2010 07:57 PM

So... Do they want the users to only have access to a "kiosk" style system, or do you need a simulated shell environment? I was a tad confused after reading your post. :)

If you just want a kiosk, I think there have been several discussions here on setting one up. The search function may be of help.

HTH
Dave

karlochacon 09-09-2010 08:06 PM

Quote:

Originally Posted by AsusDave (Post 4092976)
So... Do they want the users to only have access to a "kiosk" style system, or do you need a simulated shell environment? I was a tad confused after reading your post. :)

If you just want a kiosk, I think there have been several discussions here on setting one up. The search function may be of help.

HTH
Dave

simulated shell environment that's why the script above but I want something like when exit is typed say "Not allowed" and continue to promt again to type more commands

kopper27 09-10-2010 10:04 AM

sorry typed on the wrong thread

karlochacon 09-10-2010 10:06 AM

it fixed guys
I used exec script_name to load the script so when user type exit...the menu will log out the linux session :)

now guys as I said that code above is a simulated linux shell very basic....

is there a way to improve it?

commands like these ones won't work

Code:

/sbin/ifconfig -a | less
/sbin/ifconfig > ip

it looks like when using | or > or similar characters my simulated command line won't work

any idea how to improve this simulated command line?

thanks a lot

karlochacon 09-10-2010 03:48 PM

no problem guys
Code:

eval $whichcmd
will do the job

AsusDave 09-10-2010 08:58 PM

I am wondering, would it work better to put your users into a "restricted" group, then change the permissions on the commands you don't want them to run to not include execute permissions for that "restricted" group?

I'm just trying to advance from an alternate direction. :)

HTH
Dave

karlochacon 09-11-2010 12:55 PM

Quote:

Originally Posted by AsusDave (Post 4094034)
I am wondering, would it work better to put your users into a "restricted" group, then change the permissions on the commands you don't want them to run to not include execute permissions for that "restricted" group?

I'm just trying to advance from an alternate direction. :)

HTH
Dave


how can I achieve that? restricted groups?

AsusDave 09-11-2010 09:02 PM

Basically, you create a group, name it whatever you like (you could use "restricted" if you wanted to), depending on which distro you are using, the steps may vary a little. You then change the permissions on the programs you want to run (exit, apt-get, aptitude, yum, etc) to exclude this new group.

Now anyone you add to this group will be unable to run the commands you have "turned off"

This is the 30,000 ft view of groups, your google-fu will serve you well digging into the particulars.

HTH
Dave


All times are GMT -5. The time now is 07:47 PM.