On Fri, Feb 14, 2003 at 01:10:15PM +0100, Colin J. Raven wrote:
> Greetings all!
> Trying to create a custom login message for csh users.
> I put the following in /etc/csh.login
> <snip>
> ###############################################
> if [ `whoami` = user1 ]; then
> echo ""
> echo -e "This is a test message for user1" && \
> echo ""
> else
> if [ `whoami` = user2 ]; then
> echo ""
> echo -e "This is a test message for user2" && \
> echo ""
> else
> if [ `whoami` = test ]; then
> echo ""
> echo -e "This is a test message for user test" && \
> echo ""
> fi
> ###################################################
> </snip>
> and got an error upon subsequent login as user "test":
> "if: Expression Syntax." (without parens)
>
> Anyone got any idea what I'm doing wrong?
> Guess: csh syntax is different from bash but beyond that I'm stumped.
Further guess (but informed by a brief read-up in UNIX in a Nutshell):
The conditions for an 'if' statement should be enclosed in parentheses,
rather than using the [ or test. However, it may still do funky stuff
with the command substitution...
The block syntax for "if" statements is:
if (expr) then
cmds
endif
===========
if (expr) then
cmds
else
cmds
endif
==========
if (expr) then
cmds
else if (expr) then
cmds2
else
cmds3
endif
HTH,
Dan
--
Daniel Bye
PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc
PGP Key fingerprint: 3D73 AF47 D448 C5CA 88B4 0DCF 849C 1C33 3C48 2CDC
_
ASCII ribbon campaign ( )
- against HTML, vCards and X
- proprietary attachments in e-mail / \
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message