From owner-freebsd-questions Fri Feb 14 6: 1:14 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C955137B401 for ; Fri, 14 Feb 2003 06:01:11 -0800 (PST) Received: from catflap.home.slightlystrange.org (pc1-cmbg1-4-cust43.cmbg.cable.ntl.com [62.253.133.43]) by mx1.FreeBSD.org (Postfix) with ESMTP id AD7B043F75 for ; Fri, 14 Feb 2003 06:01:10 -0800 (PST) (envelope-from dan@slightlystrange.org) Received: from danielby by catflap.home.slightlystrange.org with local (Exim 3.36 #1) id 18jgOl-0005qV-00 for freebsd-questions@freeBSD.org; Fri, 14 Feb 2003 14:01:03 +0000 Date: Fri, 14 Feb 2003 14:01:03 +0000 From: Daniel Bye To: BSD Questions Subject: Re: syntax problem in /etc/csh.login Message-ID: <20030214140102.GB2220@catflap.home.slightlystrange.org> Reply-To: dan@slightlystrange.org Mail-Followup-To: BSD Questions References: <001c01c2d422$083c47a0$1500000a@scrk.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001c01c2d422$083c47a0$1500000a@scrk.com> User-Agent: Mutt/1.4i X-Scanner: exiscan *18jgOl-0005qV-00*FbG5sdWMwBQ* (SlightlyStrange.org, Using NOD32 http://www.nod32.com) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 > > ############################################### > 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 > ################################################### > > 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