LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-09-2010, 05:14 PM   #1
kopper27
Member
 
Registered: Nov 2009
Posts: 147

Rep: Reputation: 16
allow or not script


hi guys

I am working on a menu...
and the menu has some options like check status for services (gmonitor group) or stop - start - restart those same services (gadmin group)

as you see there are 2 main groups gmonitor for monitoring and gadmin for restart - stop - start services

so checking command groups

Code:
#groups root
root : root bin daemon sys adm disk wheel ivmgr httpd gadmin

#groups cgonza
cgonza : cgonza testing gmonitor
basically I want to read the output from groups command and atfer that

if group gadmin is found allow the user to restart services and if gmonitor group is found deny access to restart services

the point is I don't know how to get that groupvar

Code:
if [ "$groupvar" == "gadmin" ]
        then
         restart services options
       else
         echo "... you are not allowed to ..."
thanks a lot
 
Old 04-09-2010, 08:14 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
You don't need the string, using the exit value like:
Code:
groups 2>/dev/null|grep -q gmonitor; case "$?" in 
0) restart services options;; 
*) echo "... you are not allowed to ...";; 
# et cetera
should do, or if you still want to "if then" try:
Code:
if [ "${groupvar}" = "${groupvar//gadmin/}" ]; then
 echo "... you are not allowed to ..."
else
 restart services options
# et cetera
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script problem with ftp session exiting the script early edomingox Programming 5 02-23-2010 06:39 AM
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 07:19 PM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 09:40 AM
I want to run script on the server from client machine in windows in a perl script vpradeep Linux - Newbie 2 09-01-2008 04:29 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 05:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration