Go Back   The UNIX and Linux Forums > Operating Systems > Linux > Red Hat
google site



Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #1  
Old 03-14-2010
Registered User
 

Join Date: Mar 2010
Location: India
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
identifying SU mode by shell script

the following bash script is not working in fedora-11 Could anyone help me please?


Code:
#!/bin/bash

if
[$[`id -u`] -ne  0];then
       echo " you are in root"
else   echo " you must be in root -su mode??"
fi
exit


Last edited by Franklin52; 03-14-2010 at 07:50 AM.. Reason: Please use code tags!
Sponsored Links
  #2  
Old 03-14-2010
Moderator
 

Join Date: Feb 2007
Location: The Netherlands
Posts: 5,786
Thanks: 2
Thanked 94 Times in 89 Posts
Quote:
Originally Posted by Turtel View Post
the following bash script is not working in fedora-11 Could anyone help me please?


Code:
#!/bin/bash

if
[$[`id -u`] -ne  0];then
       echo " you are in root"
else   echo " you must be in root -su mode??"
fi
exit

Replace:

Code:
if [$[`id -u`] -ne  0]

with:

Code:
if [ $(id -u) -ne 0 ]

Be aware of the spaces around the square brackets.
  #3  
Old 03-15-2010
Registered User
 

Join Date: Mar 2010
Location: India
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Franklin very much..........
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Vi Mode of Shell Not Starting almond UNIX for Advanced & Expert Users 4 06-22-2009 04:58 AM
Convet Linux OS from text mode to graphic mode s_linux SuSE 6 02-07-2009 10:18 PM
Identifying prior date in shell script royalibrahim Shell Programming and Scripting 5 12-04-2008 08:38 AM
Script to ftp in non-ineractive mode mshv123 Shell Programming and Scripting 6 09-18-2007 05:45 PM
How to run shell script in silent mode x057373 UNIX for Dummies Questions & Answers 3 12-04-2005 07:26 PM



All times are GMT -4. The time now is 09:20 PM.