Re: Help with CSH please (88 Views)
Reply
Regular Advisor
dev44
Posts: 164
Registered: ‎03-20-2002
Message 1 of 6 (88 Views)

Help with CSH please

I have the following script that works great in sh/ksh. Can someone please help me with the syntax for csh. I can't get the if statement working.

Thanks

# custom code for denying generic account login
if logname > /dev/null 2>&1
then
LGNM=`logname`
if egrep "^${LGNM}$" /etc/not_loginable > /dev/null 2>&1
then
echo "\nDirect login not allowed for $LGNM\n"
echo "\nNO remote login allowed for $LGNM (`date '+%D %T'`)\n" |
sleep 3
logger -p user.err NOT_LOGINABLE
exit 1
fi
fi
whatever
Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,074
Registered: ‎02-23-2005
Message 2 of 6 (88 Views)

Re: Help with CSH please

> Can someone please help me with the syntax
> for csh.

Why csh?

> I can't get the if statement working.

man csh

"fi"? Try "endif".

man csh
Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,074
Registered: ‎02-23-2005
Message 3 of 6 (88 Views)

Re: Help with CSH please

And that's not the only thing you'd need to
change. For example:

> [...] 2>&1
Please use plain text.
Regular Advisor
dev44
Posts: 164
Registered: ‎03-20-2002
Message 4 of 6 (88 Views)

Re: Help with CSH please

The script is what I use to lock out "generic" accounts...so that they can only be "su'd" to. We have a few users who are csh and I need to make it work for those accounts
whatever
Please use plain text.
Regular Advisor
dev44
Posts: 164
Registered: ‎03-20-2002
Message 5 of 6 (88 Views)

Re: Help with CSH please

Got it.
whatever
Please use plain text.
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 6 of 6 (88 Views)

Re: Help with CSH please

Hi:

> I have the following script that works great in sh/ksh

Then why in the ?!? In HP-UX the Posix shell is your standard. In AIX, Korn is the default; in Linux, the bash shell --- all cousins. Why would you want to rewrite it in the C-shell?

If you haven't read this, you should!

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Regards!

...JRF...
Regards!

...JRF...
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation