Capturing last command execution status in a script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capturing last command execution status in a script.
# 1  
Old 04-12-2007
Capturing last command execution status in a script.

How to capture output or numeric part given by $? command into the variable?

If I go for

var=`$?`

then $var is found empty.
# 2  
Old 04-12-2007
go simpler again than what you tried...

var=$?
# 3  
Old 04-12-2007
Thanks, it worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Xargs -P command execution status

Hi, I am working on a file copier utility where I have written the copy commands to a batch file e.g. file_copier.bat which i pass to xargs command as follows. cat file_copier.bat | xargs -n 1 -P 40 I also want to record the copy command status of each file/command in the form "command... (1 Reply)
Discussion started by: ankur singh
1 Replies

2. Shell Programming and Scripting

Ed command execution in script file

for file in File_Name* do ed -s $file << 'EOF' 0a $Header_Record . $a . w EOF done The above command is executing in the unix box but is not... (2 Replies)
Discussion started by: Kanch
2 Replies

3. Shell Programming and Scripting

How to get the exit status of a command in nner script to the outer script?

Hi all, I have a shell script inside which i am executing another shell script. In the inner script im executing a command. i want the status of that command in the outer script to perform some validations. How to get its status please help!!1 Im using ksh. (2 Replies)
Discussion started by: Jayaraman
2 Replies

4. Shell Programming and Scripting

Capturing the exit status of the script running in background

Hi All, I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script. Is there a way I can capture the exit status of each individual child script after the execution is completed. (2 Replies)
Discussion started by: paragkalra
2 Replies

5. Shell Programming and Scripting

capturing C++ binary return status in perl

Hello, I have a C++ binary that runs in my perl script. But, Currently, the binary is doing a core dump and i want to capture the retrun status of the binary to report as an issue. Can you please help me on this. Thanks, Sateesh (1 Reply)
Discussion started by: kotasateesh
1 Replies

6. Shell Programming and Scripting

capturing C++ binary return status in perl

Hello, I have a C++ binary that runs in my perl script. But, Currently, the binary is doing a core dump and i want to capture the retrun status of the binary to report as an issue. Can you please help me on this. Thanks, Sateesh (1 Reply)
Discussion started by: kotasateesh
1 Replies

7. Shell Programming and Scripting

execution status of gotoURL in Win32::IEAutomation

Hi, I am using Win32::IEAutomation module to automate my Web based application. I am trying to prepare a report for the test cases I automated. The problem is I am unable to get the execution status of the commands gotoURL, getButton .... to know if my button click or url redirection is... (2 Replies)
Discussion started by: gurukottur
2 Replies

8. Shell Programming and Scripting

Status code of last command execution

Hello people, I am using KSH and inside my script I do a cksum and check the status code to see whether the command sucessfully. Here even though the cksum fails due to file not existing the status returned is still 0 because the awk command worked fine. How do I capture just the status of the... (1 Reply)
Discussion started by: tipsy
1 Replies

9. Shell Programming and Scripting

Capturing shell script command output

I am trying to check to see if a file exists on a ftp server, well, I know that cant be done, atleast directly, So I came up with this small script ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD cd public_html/crap dir $FILE quit END_SCRIPT Where the $ variable... (2 Replies)
Discussion started by: designflaw
2 Replies

10. UNIX for Dummies Questions & Answers

capturing exit status ($?) in subshell ??

I am trying to capture the exit status of a parent shell in a subshell. I am using the trap .. Exit command in the subshell I cant use the export command in the parent shell to to export a variable with the exit status to the subshell. I would have tooooo many parent shells to change. ... (2 Replies)
Discussion started by: Bob Bannon
2 Replies
Login or Register to Ask a Question