Sponsored Content
Full Discussion: Trapping program return code
Top Forums Shell Programming and Scripting Trapping program return code Post 302491562 by pavlosgr on Thursday 27th of January 2011 06:18:48 PM
Old 01-27-2011
I'm running Ubuntu 10.10, 2.6.35-24-generic kernel.

My code now looks like :

Code:
#!/bin/sh 
./prog $1 &
myPID=$!

sleep 1
kill -0 $myPID

if [ $? -ne  0 ] ; then
  echo 'process terminated'
  exit 
fi

top -p $myPID -b -d 1 -n $1 | sed -n '8~10p' | awk '{print $5}' > res.txt

It runs smoothly Smilie.
Just a slight drawback as prog should iterate $1 times grabbing some memory each time. Between each iteration it sleeps 1 sec. As my script sleeps for 1 sec I monitor $1-1 iterations than $1.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sql error code trapping

Hello #!bin/ksh sqlplus -s system/manager < |grep '^ORA' |uniq select * from kk; set echo on show spool on end; / EOF save test.sh sh test.sh results ORA-00942: table or view does not exist (3 Replies)
Discussion started by: xiamin
3 Replies

2. UNIX for Advanced & Expert Users

Return code from PL/SQL Code

Hi Guys, I was just wondering if anybody can help me with this problem. OK, how we can get a value back from PL/SQL Script (not stored procedure/function) See the below example: (for example aaa.sh) #!/bin/ksh VALUE=`sqlplus -s user/password@test_id <<EOF @xxx.sq EOF` echo $VALUE ... (7 Replies)
Discussion started by: Shaz
7 Replies

3. Shell Programming and Scripting

How to get return value from C program and logs to file

Hi, I have written scritp which prints output from the executable to standard output as well as in a file. Here "add" is an c executable which returns some value based on inputs. But if tee is not used "$?" returns the return value from add exe. If tee is used it is simply retuning 0. echo... (5 Replies)
Discussion started by: yhacks
5 Replies

4. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

5. Shell Programming and Scripting

How to capture C program return values in Kshell

I have a K shell script (ksh) that needs to return an email address. A C program was written (prog1) to now access the email address off of an oracle table. The call to the program in the ksh is prog1 -p parm1 Based on Parm1 the program will read an oracle table and retrieve the email... (2 Replies)
Discussion started by: jclanc8
2 Replies

6. Programming

Parallel Processing Detection and Program Return Value Detection

Hey, for the purpose of a research project I need to know if a specific type of parallel processing is being utilized by any user-run programs. Is there a way to detect whether a program either returns a value to another program at the end of execution, or just utilizes any form of parallel... (4 Replies)
Discussion started by: azar.zorn
4 Replies

7. Shell Programming and Scripting

Trapping SIGINT after restarting program.

Tried to add a function to my control_c interrupt here. It works but has one little bug. If the user selects to run the function instead of exiting, the program restarts itself without forking as it should. However, after that control_c no longer works again. I wanted to allow the user to run... (1 Reply)
Discussion started by: Azrael
1 Replies

8. Shell Programming and Scripting

How to end the program with a successful return code?

i have the follow shell script that try to find any file in the specified path and upload to oracle. if no file will output in the concurrent log and the program return as error , how do i change the program so that if no file found will give out normal sucessful result. i tried change the exit... (3 Replies)
Discussion started by: feilhk
3 Replies

9. Programming

Segment fault for C++ program when return vector

I am trying to reverse complement DNA sequence (string) with a short c++ code using boost library. Code was compiled without any warning/error, but ran into Segmentation fault. My guess is the function to return a vector, but not sure. #include <iostream> #include <fstream> #include <string>... (14 Replies)
Discussion started by: yifangt
14 Replies

10. Shell Programming and Scripting

Trapping the return status from FIND command

I have the following code in a script: find . \( ! -name . -prune \) -name "cg*" -exec cp -p {} "${temp_dir}" \; ret_stat=$? I think the return status is only captured for the 'find' command and not for the 'cp' command. Is there a way to get the return status for the 'cp' command... (7 Replies)
Discussion started by: vskr72
7 Replies
Utils(n)						       Tix Built-In Commands							  Utils(n)

__________________________________________________________________________________________________________________________________________________

NAME
tixUtils - Utility commands in Tix. SYNOPSIS
tixDescendants pathName tixDisableAll pathName tixEnableAll pathName tixPushGrab ?-global? window tixPopGrab _________________________________________________________________ DESCRIPTION
tixDescendants pathName Returns a list of all the descendant widgets of pathName plus pathName itself. tixDisableAll pathName Disables pathName and all its descendants. tixEnableAll pathName Enables pathName and all its descendants. tixPushGrab ?-global? window The tixPushGrab and tixPopGrab commands allows you to perform "cascade-grabbing". tixPushGrab calls the grab(n) command on window and saves window on a grabbing stack. tixPopGrab tixPopGrab pops the top-most element from the grabbing stack and release its grab. If the grabbing stack is not empty, then tixPop- Grab will execute grab(n) on the current top-most element in the grabbing stack. NOTES
Some Tix widgets (for example, tixComboBox and tixPanedWindow) grabs the screen on certain occasions using tixPushGrab and tixPopGrab. Therefore, if you need to grab the screen when these widgets are present, you should also call tixPushGrab and tixPopGrab in place of the Tk grab and grab release commands. Otherwise, the behavior of these widgets may be undefined. KEYWORDS
Tix(n), grab(n) Tix 4.0 Utils(n)
All times are GMT -4. The time now is 06:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy