1748140 Members
3663 Online
108758 Solutions
New Discussion юеВ

Help with CSH please

 
dev44
Regular Advisor

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
5 REPLIES 5
Steven Schweda
Honored Contributor

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
Steven Schweda
Honored Contributor

Re: Help with CSH please

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

> [...] 2>&1
dev44
Regular Advisor

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
dev44
Regular Advisor

Re: Help with CSH please

Got it.
whatever
James R. Ferguson
Acclaimed Contributor

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...