Menu Driven UNIX Admin


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Menu Driven UNIX Admin
# 1  
Old 03-30-2008
Menu Driven UNIX Admin

I need to have a script that can do an automated IPL function (how to reboot the box). I think ‘reboot’ would do the trick.

However, how would I go about doing it, for example if the user states from a menu script that I would like to reboot now. The problem is when I do the ‘reboot’ command I get a message (obviously) because I am not the super user. But I do have another gem network in which I have root superuser access.

So how would I from the below script which I need to write whilst I am not in super user mode do the ‘reboot’ command from the normal user mode. Is there a way of having, for example when the user chooses option 1, then it states enter the other gem network root username and password (so i am the superuser) and then be able to do the ‘reboot’ command?

I hope I have not made it difficult to understand for you.

......Code carries on for the other 3 options

Last edited by ad4m88; 03-31-2008 at 12:50 PM..
# 2  
Old 03-31-2008
If the user which has privileges is on the same machine, just start the script when you are logged with this username. Otherwise, switching the user can be done with "su -user -c command" where command can be replaced by "shutdown -r now" or "reboot" but you have to provide the password. Consider sudo as well.
# 3  
Old 03-31-2008
There's also another possibility, though I would not recommend it.
chgrp reboot command to a "reboot group", SETUID reboot command (chmod 4750), and add those "reboot allowed users" to that "reboot group".
Take into account that:
1- This is very dangerous, so consider using what sysgage suggests first.
2- reboot must be a binary file.
Regards.
# 4  
Old 03-31-2008
Im getting 'Invalid Option'

Is this correct:

Code:
echo "Would you like to reboot the box?"
        echo "Ok to procede?"; read ans

                                        case "$ans" in
                                        n*|N*)
                                        echo "-------------------------------------"
                                        echo "Machine has not been rebooted"
                                        echo "Machine has not been rebooted">>report.txt
                                        exit 0   ;;

                                        esac
                                        su -user -c shutdown -r reboot
                                        echo "-------------------------------------"
                                        echo "Machine has been rebooted"
                                        echo "Machine has been rebooted">>report.txt

# 5  
Old 03-31-2008
Quote:
Originally Posted by ad4m88

Code:
su - user -c "shutdown -r reboot"

Notice the white space Smilie
# 6  
Old 03-31-2008
Wouldn’t work ... but messed about with it ... and it worked! Thanks.

One last help.... how do i:
1) Add and delete a user (I know 'deluser' and 'adduser' does it), but in a menu type system how would I implement it? Is choosing from another submenu OK? e.g. 1.Add User 2. Delete User ... (I already have a menu, and one option is User Management, so I need to put the 'adduser/deluser' and no.2 within this option)
2) Check a user exists on the system then change a password.

Any hints of how it would be done greatly appreciated or guidance to some good online help books.

Kind Regards to all especially sysgate & grial.
# 7  
Old 03-31-2008
apropos is your friend.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using menu driven script

Hi Team , I wrote a shell script for adding and subtracting two numbers am getting error could some one please help to fix it script: echo "Enter 1 to add:" echo "Enter 2 to sub:" echo "Enter 3 for both addition and subtraction :" read ans; case "$ans" in 1)... (4 Replies)
Discussion started by: knz
4 Replies

2. UNIX for Dummies Questions & Answers

System administration tasks performed from a menu driven interface

I need to write a shell script that allows some system-administration tasks to be preformed automatically from a menu-driven interface. Automate the following tasks: • Copy directory tree • Delete files or directories • Output Information But I don't understand the question. What is a "menu... (2 Replies)
Discussion started by: femchi
2 Replies

3. Shell Programming and Scripting

Use of stty vs trap in script-driven login menu

My employers would like me to selectively run one of several different (already-existing) Korn Shell menu-driven scripts out of the user's .profile file, depending on some yet-to-be-specified user critieria. I've never done this kind of thing, but I have the existing scripts (among other... (5 Replies)
Discussion started by: Clovis_Sangrail
5 Replies

4. Shell Programming and Scripting

Menu driven script.

I'm a beginner at scripting and have been putting this script together over the past week. It's no where as polish as it could be. Any tips/suggestions on improving this script would be appreciate it. Every week, my team develops WAR files in tomcat on our test environment and moves them to our... (4 Replies)
Discussion started by: bouncer
4 Replies

5. Shell Programming and Scripting

Help needed in writing a menu driven script

Hi, I was wondering if someone could help me write a shell script in Linux that backsup/restores data to anywhere I choose but it needs to be menu driven? Thanks, I'm new to Linux/Unix but liking it so far...just hoping to get to grips with the scripts! :) (7 Replies)
Discussion started by: Nicole
7 Replies

6. UNIX for Dummies Questions & Answers

What is a menu or command line option driven script?

i'm confused what this means. i was asked to design a menu or command line option driven script that reads out of a DB and displays info such as read_data.pl -u <user> -e <event> which would print commands run by <user>with the <event> in the db. any suggestions? i've been using... (2 Replies)
Discussion started by: kpddong
2 Replies

7. Shell Programming and Scripting

Menu driven Script needed ..pls help

Hi Guys.. am new to unix scrpiting..I need a Menu need to create using shell scrpting eg: Food items ready paid if i press "f" need to add items for a file food items.. if i press "r" it need to move into ready and remove from food items if i press "p" need to update a filed in... (1 Reply)
Discussion started by: sasdua
1 Replies

8. Homework & Coursework Questions

Menu Driven Shell Script which accepts1 to 5 options

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 1) Write a Menu Driven Shell Script which accepts1 to 5 options and performs the following actions for... (1 Reply)
Discussion started by: vaghya
1 Replies

9. UNIX for Advanced & Expert Users

Menu driven using Ksh

Hi Guys, I would like to know how to write Menu driven programs using ksh. I have several script files 1.sh 2.sh 3.sh ...so on 25 files I want to create a Menu which will calls submenus. Main Menu 1. Data Entry if you press 1 again submenu 1. Order entry ... (3 Replies)
Discussion started by: krishna
3 Replies

10. Programming

menu driven ( like pine) on Linux

Hi guys, I am designing the rdbms in C/C++ on linux platform as my project. Can any one help me in designing menu driven screen (like the pine ) which will print on screen as follows 1) create table 2) add table ............. etc with arrow keys for... (2 Replies)
Discussion started by: amit
2 Replies
Login or Register to Ask a Question