Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Feb 2003 01:23:31 +1100
From:      Sam Izzo <izzo@humbug.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: syntax problems in /etc/csh.login
Message-ID:  <20030214142330.GA25701@kalgan.vic.optushome.com.au>

index | next in thread | raw e-mail

Hi,

Try this instead:

if ( $user == user1 ) then
   echo hello user1
else if ( $user == user2 ) then
   echo hello user2
endif

You could also do it with a switch:

switch ( $user )
   case user1:
      echo hello user1
      breaksw
   case user2:
      echo hello user2
      breaksw
endsw

$user is a shell built-in variable that holds the user's login name.

If you have a lot of users you might want to do it via some username-message
mapping mechanism instead of coding a whole bunch of if or case statements.  A
simple method might be to have a directory under /etc called, say, "usermsg"
and then a file for each user.  Then in your csh.login you'd do something like:

if ( -r /etc/usermsg/$user ) then
   cat /etc/usermsg/$user
endif

cheers
sam


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030214142330.GA25701>