How to get exit value of an executable that gets called from function?


 
Thread Tools Search this Thread
Top Forums Programming How to get exit value of an executable that gets called from function?
# 1  
Old 09-08-2004
Java How to get exit value of an executable that gets called from function?

How to get exit value of an executable that gets called from function?

I have an executable called “myexec” which returns 0 on success and different values for different fail scenarios.

I need to call this (myexec) executable from “myprog()” function of other executable and get the exit value (return value) of it. I tried with “system()” call but it doesn't returns the exit-value of “myexec”.

Is there any other way to solve my problem??

Thanks in advance,

Regards,
SureshReddi.
# 2  
Old 09-09-2004
Thanks Driver it works for me.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies

2. Shell Programming and Scripting

Function getting called recursively

I have the below script which creates a directory or simply terminates without throwing error (exit 1) incase the directory exists. bash-4.1$ vi mdir.sh #!/bin/bash -e shopt -s expand_aliases alias mkdir=mkdir_s mkdir_s(){ if ]; then echo " directory EXISTS " return else echo "... (3 Replies)
Discussion started by: mohtashims
3 Replies

3. UNIX for Dummies Questions & Answers

Find exit with success with non executable directory

Hi there, I'm quite surprised by the following behavior of find. $ find -ls # I have a directory and a file in it 8145 4 drwxr-xr-x 3 me me 4096 May 10 09:36 . 87 4 drwxr-xr-x 2 me me 4096 May 10 09:36 ./dir 88 0 -rw-r--r-- 1 me me 0... (2 Replies)
Discussion started by: chebarbudo
2 Replies

4. UNIX for Dummies Questions & Answers

Problems with "exit" called from function in bourne script

Hi everyone. #!/sbin/sh EXITING() { umount /FOLDER rm -Rf /FOLDER echo "EXIT" exit 0 } EXITING echo "OK" (8 Replies)
Discussion started by: vacadepollo
8 Replies

5. UNIX for Dummies Questions & Answers

shell program- how many times a function is called

We have a program source C and is required to indicate how many times each function is called from the C program. also print the line number where there is a call. I've tried something like this: #!/bin/sh for i in $*;do if ! then echo $i is not a C file. else echo $i... (0 Replies)
Discussion started by: oana06
0 Replies

6. UNIX for Advanced & Expert Users

Function not called when no arguments is passed

Hi Guys, I am trying to pass arguments to the script i am wrinting. When no argument is passed or wrong argument is passed, the script needs to output the way it needs to be called and exit. Currently, when no arguments is passed, it is not getting exited but goes on assuming those... (3 Replies)
Discussion started by: mac4rfree
3 Replies

7. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

8. Shell Programming and Scripting

Exit shell after setting executable to run?

Hi, I have an executable file that has a rather long and tedious process to complete. How would I launch the executable using the shell, and then exit the shell while leaving the executable to run in the background? (1 Reply)
Discussion started by: pcwiz
1 Replies

9. Shell Programming and Scripting

exit from case - called in a function

Hello Experts, I am building a shell where I need to use case structure. The structure is in a function as in the sample code below: # Shell mySh #!/bin/sh doThis(){ var=$1 case "$var" in IT) echo "ok 1 $var" ;; ... (7 Replies)
Discussion started by: hkansal
7 Replies

10. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies
Login or Register to Ask a Question