1752675 Members
5715 Online
108789 Solutions
New Discussion юеВ

TCSH and CSH commands

 
GaneshrajS
Advisor

TCSH and CSH commands

Hi,

Will you please help me in converting the following commands to TCSH and CSH commands?

commands:-
tty > $1/.ttyvalue
ps -ef | grep $1 | tr -s ' ' | cut -d ' ' -f3 > $1/.processvalue
while :
do
sleep 10
done

Thanks,
Ganeshraj.S
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: TCSH and CSH commands

You don't. You leave them in a real shell:

#!/usr/bin/ksh
tty > $1/.ttyvalue
ps -ef | grep $1 | tr -s ' ' | cut -d ' ' -f3 > $1/.processvalue
while : ; do # Not sure why you want this infinite loop here?
sleep 10
done

And from your scummy C shell:
call_real_shell_for_something user-name
OldSchool
Honored Contributor

Re: TCSH and CSH commands

i've not looked at csh in years, but 5 minutes with the "man" page seems to indicate that the only difference would be the "while" construct.

must admit, I'm at a loss as to what you would do with this infinite loop, as the loop doesn't actually "do" anything, so it seems rather pointless
GaneshrajS
Advisor

Re: TCSH and CSH commands

Hi,
Thanks for your replies. :)
I need to make sure these commands executes in TCSH and CSH shell.

Is that including(at 1st line) #!/usr/bin/tcsh will work for tcsh and #!usr/bin/csh will work for csh?

-Kindly dont worry about the infinite loop. We will take care of it. :)

Since I never worked on these shells, I need assistance.

-Ganeshraj.S
James R. Ferguson
Acclaimed Contributor

Re: TCSH and CSH commands

Hi:

> I need to make sure these commands executes in TCSH and CSH shell.

Why not simply test your scripts?

> Is that including(at 1st line) #!/usr/bin/tcsh will work for tcsh and #!usr/bin/csh will work for csh?

Yes, all scripts should specify the interpreter that they want to use. This is done with the 'shebang' line. For the HP-UX Posix shell this is:

#!/usr/bin/sh

> Since I never worked on these shells, I need assistance.

I have never used the 'tcsh' but I understand it is quite viable if that is your choice. The 'csh' is brain-damaged and should be avoided:

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

Whatever you elect to do, do _NOT_ change 'root's shell. It must remain as '/sbin/sh' [ a staticly linked version of the Posix shell ] or your server will be rendered un-startable!

Regards!

...JRF...
OldSchool
Honored Contributor

Re: TCSH and CSH commands

Me: "but 5 minutes with the "man" page seems to indicate that the only difference would be the "while" construct."

GaneshrajS: "Since I never worked on these shells, I need assistance."

Then you might start by looking at the aforementioned "man" page, in particular the item noted.