Date: Fri, 14 Feb 2003 14:01:03 +0000 From: Daniel Bye <dan@slightlystrange.org> To: BSD Questions <freebsd-questions@freeBSD.org> Subject: Re: syntax problem in /etc/csh.login Message-ID: <20030214140102.GB2220@catflap.home.slightlystrange.org> In-Reply-To: <001c01c2d422$083c47a0$1500000a@scrk.com> References: <001c01c2d422$083c47a0$1500000a@scrk.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030214140102.GB2220>