identifying SU mode by shell script

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat identifying SU mode by shell script
# 1  
Old 03-14-2010
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 09:50 AM.. Reason: Please use code tags!
# 2  
Old 03-14-2010
Quote:
Originally Posted by Turtel
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
Thanks Franklin very much..........
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell vim defaulting to Insert or Command mode

On a daily basis I need to SSH into several different RHEL servers using Putty. On some of the servers, if I up arrow to get a previous command, it automatically starts in Input Mode, so if I press up arrow, then 'x' it will type the letter x at the end of the command line. On other servers, it... (4 Replies)
Discussion started by: derndingle
4 Replies

2. HP-UX

From a C++ application how to find if a hpux host is in standard mode or trusted mode

is there a way for my C++ application to find out which mode the hpux OS is running in? standard mode or trusted mode. (3 Replies)
Discussion started by: einsteinBrain
3 Replies

3. Shell Programming and Scripting

Help with Perl script for identifying dupes in column1

Dear all, I have a large dictionary database which has the following structure source word=target word e.g. book=livre Since the database is very large in spite of all the care taken, it so happens that at times the source word is repeated e.g. book=livre book=tome Since I want to... (7 Replies)
Discussion started by: gimley
7 Replies

4. Shell Programming and Scripting

Debugging mode while executing Unix Shell Scripting

Hi, Is there any debugging tool for Unix Shell Script like we have gdb in C/C++? Also please let me know how to close the thread is it automatic or we have to close it manually. Thanks and Regards (1 Reply)
Discussion started by: diehard
1 Replies

5. Shell Programming and Scripting

Awk - Script assistance on identifying non matching fields

Hoping for some assistance. my source file consists of: os, ip, username win7, 123.56.78, john win7, 123.56.78, paul win7, 10.1.1.1, john win7, 10.2.2.3, joe I've been trying to run a script that will only return ip and username where the IP address is the same and the username is... (3 Replies)
Discussion started by: tekvaio
3 Replies

6. Shell Programming and Scripting

Script for identifying and deleting dupes in a line

I am compiling a synonym dictionary which has the following structure Headword=Synonym1,Synonym2 and so on, with each synonym separated by a comma. As is usual in such cases manual preparation of synonyms results in repeating the synonym which results in dupes as in the example below:... (3 Replies)
Discussion started by: gimley
3 Replies

7. Shell Programming and Scripting

Logging perl and shell debug mode.

I have a shell program which calls a perl program. I am running the shell program with command; $ ksh -x <prog_name> Inside the shell program, I am calling perl with warnings. I want to capture the entire output as it comes on screen. The command I tried is: $ ksh -x... (1 Reply)
Discussion started by: som.nitk
1 Replies

8. UNIX for Advanced & Expert Users

Vi Mode of Shell Not Starting

Hi all, I wish to use the vi mode of UNIX shell. For this, I did the following: # set -o vi Next when I write a few letter on the prompt and press 'Esc' and 'v', I am not taken to the vi mode. I could start the vi mode on other unix systems, in the manner same as above, but unable... (4 Replies)
Discussion started by: almond
4 Replies

9. Shell Programming and Scripting

Identifying prior date in shell script

Hi guys, I'm a newbie to shell script. I have to write a shell script that is supposed to give me a date which should be older than the current date when I supply "no. of days" as a command line parameter to the script. (i.e)., if I am giving the no. of days value as 305, the script should... (5 Replies)
Discussion started by: royalibrahim
5 Replies

10. UNIX for Dummies Questions & Answers

How to run shell script in silent mode

Hi, I have a AIX shell script that normally runs in an interactive mode. Now there is a need to it in silent mode and take all default answers. How do I do that? Thanks. (3 Replies)
Discussion started by: x057373
3 Replies
Login or Register to Ask a Question