[98642] in RedHat Linux List

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

Re: A script problem

daemon@ATHENA.MIT.EDU (Rick L. Mantooth)
Mon Nov 9 22:29:00 1998

Date: Mon, 9 Nov 1998 21:26:50 -0600 (CST)
From: "Rick L. Mantooth" <rickdman@cyberramp.net>
To: Zoki <zokiphoto@magic.fr>
cc: Red Hat Users List <redhat-list@redhat.com>
In-Reply-To: <Pine.LNX.4.05.9811091701400.8047-100000@winbuster.magic.fr>
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

Zoki,
Just because I haven't seen it and I'd do it this way ;)

#!/bin/sh
#
case ${LOGNAME} in	# Some 'nixes use ${USER}, some don't.
zokiphoto)
	commands ;
	;;
root)
	commands ;
	;;
*)
	exit stuff ;
	;;
esac

Rick

On Mon, 9 Nov 1998, Zoki wrote:

> 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.
> 
> 
--
Rick L. Mantooth	rickdman@cyberramp.net
http://www.cyberramp.net/~rickdman
It's lonely at the top, but you eat better.


-- 
  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