Sponsored Content
Top Forums Shell Programming and Scripting Returning values from child to parent shell Post 78004 by acheepi on Thursday 14th of July 2005 12:00:13 PM
Old 07-14-2005
Returning values from child to parent shell

I need to send the status from child shell failure to parent shell. I would like to know how could we accomplish this.


My parent.sh is as below:

#!/bin/ksh
set -x
echo "I am in parent shell now..."
child.sh
ret_stat=$?
echo "rest_stat=$ret_stat"
echo "I am below parent shell end..."


My child.sh is as below:
#!/bin/ksh
set -x
cho "I am in child shell now..." > test.log 2>&1
if [[ $? -ne 0 ]]
then
exit 100
fi
echo "I am in child shell end.."

I would like to capture the failure status from child.sh The statement in bold in child.sh is mistyped. I would like the 100 (failure) status sent to parent shell. Note that I would also like to re-direct my output to test.log at the same time.

Per above, I get success(0) status in my parent.sh ret_stat variable after the call to child.sh. This is happening because of redirection into the log file.
I would like the child shell to return 100 (failure) to parent ret_stat variable.

Let me know how would we accomplish this with the re-direction to log in the child.

Hope I made my self clear.

Thanks,
AC
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Returning Values (shell Script)

I have an application on Informix 4GL, and I am invoking the shell script from the program, but I need to know if the shell script work fine or not, in order to continue the process. I know that we can use $? to get the final status but this is on unix command. How can I return a value from the... (3 Replies)
Discussion started by: jennifer01
3 Replies

2. Shell Programming and Scripting

returning to the parent shell after invoking a script within a script

Hi everybody, I have a script in which I'm invoking another script which runs in a subshell. after the script is executed I want to return to the parent shell as some variables are set. However i'm unable to return to my original shell as the script which i'm calling inside is invoked in... (5 Replies)
Discussion started by: gurukottur
5 Replies

3. Shell Programming and Scripting

parent shell is waiting upon the child shell

Hi, I haev to devlop a script which when executed will take in a sudo privelege and run a set of commands then will go back to parent shell and execute the rest of the command But the problem I am facing is that when the script is executed it takes the sudo privelege but it waits for the... (0 Replies)
Discussion started by: ruchirmayank
0 Replies

4. Shell Programming and Scripting

Parent/child Korn shell script help

I have the following two Korn shell scripts: SHELL1.ksh #!/usr/bin/ksh nohup sas /abc/123/sasprogram1.sas & SHELL2.ksh #!/usr/bin/ksh ./SHELL1.ksh wait nohup sas /abc/123/sasprogram2.sas & My goal is to run SHELL1.ksh within SHELL2.ksh. SHELL1.ksh runs sasprogram1.sas. I would like... (1 Reply)
Discussion started by: sasaliasim
1 Replies

5. Homework & Coursework Questions

Need help with deleting childīs parent and child subprocess

1. The problem statement, all variables and given/known data: I need to make an program that in a loop creates one parent and five children with fork(). The problem i'm trying to solve is how to delete the parent and child of the childīs process. 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: WhiteFace
0 Replies

6. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

7. Shell Programming and Scripting

Propagate exist status from a child shell script to a parent.

Hi All, I have a parent shell script A and a child shell script B. 1). If a command i.e a mysqdump fails in shell script B fails then I trap the error with this code if ] then func_exit "Failed to export the cleaned DB1.${MYDBNAME} database to the ${MYARCHIVEDIR} directory"... (1 Reply)
Discussion started by: daveu7
1 Replies

8. Programming

two-way piping values between parent and child

Hello everyone. I'm pretty new to the topic of fork(), pipe() etc. All day I've been trying to make my code execute but it doesn't seem to be working the way I understand it. :wall: Anyway, my task is: Create a child process that will recive from its parent two intiger values. Than it will... (5 Replies)
Discussion started by: jakubs11
5 Replies

9. Shell Programming and Scripting

Child exiting and not returning to parent script

I am having a parent scripts which reads a file with child scripts name. I need to read one by one child script , execute it and 1. If child script fails send mail to the team with the log file 2. If the child script executes fine then proceed with the next child script execution. #!... (3 Replies)
Discussion started by: nw2unx123
3 Replies

10. Shell Programming and Scripting

Returning multiple values in Shell

Hi I have a code as the following #!/usr/bin/ksh set -x row() { a=$1 b=$2 c=$(($a + $b)) d=$(($a * $b)) echo $a $b } e=`row 2 3` set $e echo "The value of c is $c" echo "The value of d is $d" My requirement is I need to pass two arguments to a function and return two values... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies
XtCreatePopupShell()													      XtCreatePopupShell()

Name
  XtCreatePopupShell - create a popup shell widget.

Synopsis
  Widget XtCreatePopupShell(name, widget_class, parent, args, num_args)
	 String name;
	 WidgetClass widget_class;
	 Widget parent;
	 ArgList args;
	 Cardinal num_args;

Inputs
  name	      Specifies the resource name for the created shell widget.

  widget_class
	      Specifies the widget class pointer for the created shell widget; must be shellClass or any subclass.

  parent      Specifies the parent widget; must be of class Core or any subclass thereof.

  args	      Specifies the argument list to override the resource defaults.

  num_args    Specifies the number of arguments in the argument list.

Returns
  A widget of class widget_class created as a popup child of parent.

Description
  XtCreatePopupShell()	checks	that  widget_class  is a subclass of Shell, and, if it is, creates a widget of that class.  The widget is not
  stored in the children array (maintained by Composite widgets), but rather in the popup_list array (which all widgets have).

  The screen resource for this widget is determined by first scanning args for the XtNscreen resource.	If it  is  not	found,	the  resource
  database  associated	with  the  parent's screen is queried.	If both queries fail, the parent's screen is used.  Once the screen is deter-
  mined, the resource database associated with that screen is used to retrieve all remaining resources for the widget not specified in args.

Usage
  All shell widgets other than those created by XtAppInitialize() and XtAppCreateShell() must be created  with	XtCreatePopupShell().	Popup
  shells can be a child of any widget, not just Composite widgets.  Remember that shell widgets can only have a single child, which will gen-
  erally be the layout widget that arranges whatever grandchildren widgets are to appear in the popup.

  Creating and realizing a popup shell widget is not enough to make it visible.  To make a shell pop up, use XtPopup() or one of  the  prede-
  fined callback procedures or menu actions that call this function.  To make it popdown, call XtPopdown().

  Rather  than	initializing  an ArgList to pass to XtCreatePopupShell(), you can call XtVaCreatePopupShell() which accepts a NULL-terminated
  variable length argument list of resource names and resource values.

See Also
  XtCallbackExclusive(1), XtMenuPopup(1), XtPopdown(1), XtPopup(1), XtVaCreatePopupShell(1).

Xt - Pop Ups														      XtCreatePopupShell()
All times are GMT -4. The time now is 09:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy