[98518] in RedHat Linux List

home help back first fref pref prev next nref lref last post

Re: A script problem

daemon@ATHENA.MIT.EDU (Zoki)
Mon Nov 9 16:32:02 1998

Date: Mon, 9 Nov 1998 17:05:09 +0100 (CET)
From: Zoki <zokiphoto@magic.fr>
To: Red Hat Users List <redhat-list@redhat.com>
In-Reply-To: <Pine.LNX.4.05.9811091555420.8047-100000@winbuster.magic.fr>
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

On Mon, 9 Nov 1998, Zoki wrote:

->I can't seem to understand where I'm making the mistake in the next
->script. Basically, it has to test for the username and accordingly start
->other scripts. I figured out I should be using "id", export it and then do
->an if construction to test for the name of the user. The script seems to
->scip the "testing part" and goes straight to the else statement. Where
->would be the problem? Keep in mind I'm only starting with scripting.
->
->
->********* The script *********************
->
->#!/bin/sh
->
->if  [ '/usr/bin/id -un' = "zokiphoto" ]; then
->	### commands ###
->elif [ '/usr/bin/id -un' = "root" ]; then
->	### commands ###
->else
->	### exit message ###
->exit 1
->fi


*** I couldn't sit still so I went on messing around with the script. At
this point it works, but I still would like to get feedback if it's done
according to the rules. This is the solution I found:

********* The script *********************

#!/bin/sh

'/usr/bin/id -un'=USER

if  [ "$USER" = "zokiphoto" ]; then
	### commands ###
elif [ "$USER" = "root" ]; then
	### commands ###
else
	### exit message ###
exit 1
fi

Is it okay?

Zoki.
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
ZOKImage Paris
	Creation d'images est traitement numerique
			Image creation & digital tweaking
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/

Mailed with Linux and Pine.


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post