getting return status of a command in csh

getting return status of a command in csh

Post by Shea Marti » Wed, 25 Aug 2004 05:45:05



In bash, I can use $? to get the return status of the last command executed.
How do I do the equivilant in csh?

Thanks

~Shea M.

 
 
 

getting return status of a command in csh

Post by Tony Curti » Wed, 25 Aug 2004 05:48:00


>> On Mon, 23 Aug 2004 14:45:05 -0600,

> In bash, I can use $? to get the return status of the last
> command executed.  How do I do the equivilant in csh?

man csh ->

    Environment Variables and Predefined Shell Variables ->

        status

hth
t

 
 
 

getting return status of a command in csh

Post by Shea Marti » Wed, 25 Aug 2004 06:57:07



>>>On Mon, 23 Aug 2004 14:45:05 -0600,

>>In bash, I can use $? to get the return status of the last
>>command executed.  How do I do the equivilant in csh?

> man csh ->

>     Environment Variables and Predefined Shell Variables ->

>         status

> hth
> t

Thanks,

I did peruse the man page, but I was looking of for something cryptic like
bourne's $?.

~S

 
 
 

getting return status of a command in csh

Post by Rich Tee » Wed, 25 Aug 2004 07:41:28



> I did peruse the man page, but I was looking of for something cryptic like
> bourne's $?.

Why are you wasting your time scripting stuff in csh?  Do
a search for "csh why not" to see why it's best avoided.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming",
published in August 2004.

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich

 
 
 

getting return status of a command in csh

Post by Beard » Wed, 25 Aug 2004 16:42:17




>>I did peruse the man page, but I was looking of for something cryptic like
>>bourne's $?.

> Why are you wasting your time scripting stuff in csh?  Do
> a search for "csh why not" to see why it's best avoided.

Rich, hmm..... I always thought that csh was not the ideal shell to use
(AKA junk). Thus I was very surprised to see that Sun's Looking Glass
project has most (if not all) of its scripts written in csh. Any
thoughts as to why? I s'pose I could always email Hideya, or post on an
lg3d forum...
 
 
 

getting return status of a command in csh

Post by Rich Tee » Thu, 26 Aug 2004 02:29:54



> Rich, hmm..... I always thought that csh was not the ideal shell to use
> (AKA junk). Thus I was very surprised to see that Sun's Looking Glass
> project has most (if not all) of its scripts written in csh. Any

Oh dear...

Quote:> thoughts as to why? I s'pose I could always email Hideya, or post on an
> lg3d forum...

That's what I'd do.  My guess is that Hideya uses csh (or a derivative)
as his usual interactive shell, so naturally wrote the scripts in it.
Nothing wrong with using csh as your shell of choice, but writing
scripts in it is NOT a good practice, IMHO.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming",
published in August 2004.

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich

 
 
 

getting return status of a command in csh

Post by Beard » Thu, 26 Aug 2004 04:42:32




>>Rich, hmm..... I always thought that csh was not the ideal shell to use
>>(AKA junk). Thus I was very surprised to see that Sun's Looking Glass
>>project has most (if not all) of its scripts written in csh. Any

> Oh dear...

Indeedi.

Quote:

>>thoughts as to why? I s'pose I could always email Hideya, or post on an
>>lg3d forum...

> That's what I'd do.  My guess is that Hideya uses csh (or a derivative)
> as his usual interactive shell, so naturally wrote the scripts in it.
> Nothing wrong with using csh as your shell of choice, but writing
> scripts in it is NOT a good practice, IMHO.

Agreed - and your O should not be H ;-)
 
 
 

getting return status of a command in csh

Post by Rich Tee » Thu, 26 Aug 2004 07:58:53



> Agreed - and your O should not be H ;-)

Some people think I need to be more H!  :-)

*Shrug* Ah well, ya can't please 'em all...

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming",
published in August 2004.

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich

 
 
 

1. return status of commands run in su - <name> -c "<command>"

Hi

I was wondering how you can get the return status of a command which is run
within the context of su - <name> -c "<command>"

I am trying to find out the status of my command, but it always returns 0

su - dbsa -c "
$DB_DIR/dbinfo
echo $?
"

even if the dbinfo command fails, it will print out 0. Is there any way to
get the actual return status?

Note if I "su - dbsa" on the command line, run the command and have it fail,
it will return a non-zero return code.

Thanks

Ted

2. emacs arrow keys & X - anyone?

3. getting status from first command in a piped command line

4. TR and DR with modemstat .. how ?

5. Return status of commands: tcsh

6. Solaris backup (Legato )

7. ioctl(USCSICMD) S-x86: no scsi status returned for commands that fail

8. NEWS-INDIA: Free software speedens up a bulky phone directory...

9. Is there a *REAL* mt command for AIX ( that returns real status! )

10. Returning Control to a csh Script after a Background Command

11. getting the return value of a command executed on another host

12. best practice for getting exit status of pipeline commands (bash, ksh, etc)

13. Getting a return code of an earlier command