cancel
Showing results for 
Search instead for 
Did you mean: 

trace in csh

 
SOLVED
Go to solution
Jose_C_Moraes
Super Advisor

trace in csh

Hi, I need help.

Does anyone know if there is a similar csh command similar to the sh trace command set -x?

TIA, regards
Jose
11 REPLIES
James R. Ferguson
Acclaimed Contributor

Re: trace in csh

Hi Jose:

Yes, you have this one and others for tracing:

http://docs.hp.com/en/B2355-60130/csh.1.html

Of course, use 'csh' at your own risk :-)

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

Regards!

...JRF...
Jose_C_Moraes
Super Advisor

Re: trace in csh

Thanks for your reply.

It is not a choice using csh, but SAP's option.

I have alredy looked at faqs.org, but did not find anything.

In the man too. Could you, please, pinpoint the command or the question ?

Regards
Jose
James R. Ferguson
Acclaimed Contributor

Re: trace in csh

Hi (again) Jose:

Add the '-x' to your shell interpreter (shebang) line, like this:

#!/usr/bin/csh -x

Regards!

...JRF...
Jose_C_Moraes
Super Advisor

Re: trace in csh

Thanks, James.

But there is no way to trace just a few lines in a script, like set -x and set +x in posix ?

Regards
Jose
OldSchool
Honored Contributor
Solution

Re: trace in csh

from the "man" page regarding "builtin variables"

"echo"
This variable is set by the -x command line option. If set, all built-in commands and their arguments are echoed to the standard output device just before being executed. Built-in commands are echoed before command and file name substitution, since these substitutions are then done selectively. For non-built-in commands, all expansions occur before echoing."

i believe that "setenv echo..." and "unset echo" may get you what you want
Steven Schweda
Honored Contributor

Re: trace in csh

> i believe that "setenv echo..." [...]

Wouldn't you think that "setenv" is a bit of
overkill for something which only this shell
cares about? "man csh" suggests that
something like:
set echo = 1
or:
set verbose = 1 # For "-v"
would work.

One easy way to find out...
Peter Nikitka
Honored Contributor

Re: trace in csh

Hi,

don't use 'setenv echo' - do it like this:

...
set echo
...
foreach var (a b c)
echo $var
end
...
unset echo
...

This will trace only the lines between the 'set echo' and 'unset echo'.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Armin Kunaschik
Esteemed Contributor

Re: trace in csh

If SAP uses csh (BTW: for the login shell only) this should not prevent you from using ksh for your scripts. In fact, if you use the standard installation procedure, all profiles are created as (k)sh and csh versions. Look for any .??*env* in SIDadm's home! Just make sure your script starts with "#!/usr/bin/ksh" and are executable, source the according env file and everything will work fine.

On the other hand, if you want to trace/debug an existing script, you have no choice.

My 2 cents,
Armin
And now for something completely different...
Jose_C_Moraes
Super Advisor

Re: trace in csh

Sorry, I am out of town, will be back tomorrow to do the tests

Regards
Jose
Jose_C_Moraes
Super Advisor

Re: trace in csh

Hi Armin

It is only the login shell. All of the others are posix shell.

Regards
Jose
Jose_C_Moraes
Super Advisor

Re: trace in csh

The suggested trace works fine.

Thanks you all for the help.

Regards
Jose