Results 1 to 3 of 3
Hi All.
I'm new to shell scripting and have a doubt related to c shell.
How does one find the exit status / return status of the last command run ...
- 04-17-2007 #1Just Joined!
- Join Date
- Jan 2007
- Posts
- 5
Exit status / return status in c shell
Hi All.
I'm new to shell scripting and have a doubt related to c shell.
How does one find the exit status / return status of the last command run ?
In windows I can access it using %ERRORLEVEL%. Can someone please let me know the equivalent in a c shell ?
Thanks in advance,
Parag P. Doke
http://paragpdoke.blogspot.com
- 04-17-2007 #2Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi, Dokes.
Welcome to the forum.
The variable you are looking for is status. You obtain the contents with $status.
That's noted around line 3400 of the lengthy man page for tcsh.
Most people recommend using the Bourne shell family of shells rather than the csh family for scripting because of numerous drawbacks -- see http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
Best wishes ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 04-18-2007 #3Just Joined!
- Join Date
- Jan 2007
- Posts
- 5
Hi Drl.
Many thanks for sharing the information. Yes, I have also read in some websites that bash is better for scripting than c shell....however, I had some existing scripts to be modified for including $status.
Going forth (if I create new scripts), I'll try to go in for bash.
Thanks again for your support.
Regards,
Parag P. Doke
http://paragpdoke.blogspot.com


Reply With Quote