how ro use return from a child script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how ro use return from a child script
# 1  
Old 12-02-2008
how ro use return from a child script

I use return <value> to return a value from inside an else condition in child script to parent script and i am getting the following error.What is this sourced script? Can I return value to a different script using return statement.

return: can only `return' from a function or sourced script
# 2  
Old 12-02-2008
You can if you 'source' the script instead of executing it.

source a script:
. /path/to/script.sh

execute the same script:
/path/to/script.sh

Check the man page for return
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Return: can only `return' from a function or sourced script

Not sure where the problem is. I can run the script without any issue using the following command. . /opt/app/scripts/cdc_migration.sh But it fails with the below error when I try it this way /opt/app/scripts/cdc_migration.sh /opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies

2. Shell Programming and Scripting

How to capture exit code of child script and send it to parent script?

#!/usr/local/bin/bash set -vx /prod/HotelierLinks/palaceLink/bin/PalacefilesWait /prod/HotelierLinks/palaceLink/bin/prodEnvSetup 03212013 & if then echo "fatal error: Palace/HardRock failed!!!!" 1>&2 echo "Palace Failed" | mail -s "Link Failed at Palace/HardRock" -c... (1 Reply)
Discussion started by: aroragaurav.84
1 Replies

3. UNIX for Dummies Questions & Answers

Why is the return code of child required by parent ?

Hello everyone, I am a complete newbie to UNIX. I am using Debian LXDE 64-bit. I have a question regarding the child and parent process communication. According to wikipedia.org and various other sources, when a child process exits it sends the SIGCHLD signal to its parent... (1 Reply)
Discussion started by: sreyan32
1 Replies

4. Shell Programming and Scripting

Stop child script by stoping parent script

Hi everyone, I have this problem with a script I'm writting. I want to execute a code running in the background several times through a script. I am writting it like that parent_script for a in 1 2 3 4 5 do exec test -n $a done What I want to do is when parent_script is killed,... (0 Replies)
Discussion started by: geovas
0 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. Programming

getting the return from forked child process to parent in C++

This needs to work on HPUX and Linux. I do a fork and create a child process. During execution of the child process, it is possible child become lost or get killed. That is the reason why I create the child process. However if the child process doesnt get killed, I do want to know the return... (2 Replies)
Discussion started by: usustarr
2 Replies

7. UNIX for Advanced & Expert Users

Capture child processes and change return values question

Thanks in advance. My environment is Ubuntu 9.04 desktop customized to be a high school classroom server for teaching code development. I have a unique "fake" jail called "lshell" which is very easy to setup and restricts users to commands that I dictate DISALLOWING ANYTHING ELSE. These... (6 Replies)
Discussion started by: tuxhats
6 Replies

8. Shell Programming and Scripting

How to return control from the child script to the parent one?

I have two shell scripts : A.sh and B.sh A.sh echo "In A" exec B.sh echo "After B" B.sh echo "In B" The output is : In A In B I want the output : In A In B After B (4 Replies)
Discussion started by: suchismitasuchi
4 Replies

9. Programming

getting the return code of forked child process (ftp)

Hi, From within my C++ program, I fork a child process and execl an ftp session (solaris), like this : std::string szStartCmd = "ftp -i -n -v 192.168.149.31"; int nExecRes = execl("/bin/sh", "sh", "-c", szStartCmd.c_str(), (char *)0); I use 2 pipes to communicate between my... (7 Replies)
Discussion started by: KittyJ
7 Replies

10. Shell Programming and Scripting

return valuse from child script to parent script

Hi, I am trying to return a value from child script to a parent script just as a function does. The child script will look for a file and if exists will return 1 else 0. I need to capture the status 1 from child script in the parent script and proceed further. if 0, i need not do... (1 Reply)
Discussion started by: borncrazy
1 Replies
Login or Register to Ask a Question