08-28-2008
Child returning data to parent
What you are asking is for a child (called) process to return info to parent (master) program. The construct of unix does not allow for this as whatever is learned by the child does not have a way to naturally pass to parent; the reverse is ok, and is often accomplished with an EXPORT command.
Searching this forum will probably provide several creative solutions. Some are:
(a) return the value by way of the exit error parameter of the child back to the parent
(b) have the child write the data to a temporary file that the parent can then read
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I'm trying to assign the output of a command to a variable and then concat it with another string, however, it keeps overwriting the original string instead of adding on to the end of the string.
Contents of test.txt --> This is a test
var1="`head -n 1 test.txt`"
echo $var1 (This is a... (5 Replies)
Discussion started by: oma04
5 Replies
2. Shell Programming and Scripting
I have the sql file cde.sql with the below contents:
abcdefghij
abcwhendefothers
sdfghj
when no one else
when others
wwhen%others
exception when others
Now I want to search for the strings containing when others together and ceck whether that does not occur more than once in the... (2 Replies)
Discussion started by: kprattip
2 Replies
3. Shell Programming and Scripting
hi,
I want to assign find command result into some temporary variable:
jarPath= find /opt/lotus/notes/ -name $jarFile
cho "the jar path $jarPath"
where jarPath is temporary variable.
Can anybody help on this.
Thanks in advance
----Sankar (6 Replies)
Discussion started by: sankar reddy
6 Replies
4. Shell Programming and Scripting
When I run time -p <command>, it outputs:
real X.XX
user X.XX
sys X.XXwhere X.XX is seconds. How I can take just that first number output, the seconds of real time, and assign that to a variable? (9 Replies)
Discussion started by: jeriryan87
9 Replies
5. UNIX for Dummies Questions & Answers
Hello
I am using unix CLI commands for the Synergy CM software. The command basically searches for a folder ID and returns the names of the projects the folder sits in. The result is assigned to a variable:
FIND_USE=`ccm folder -fu -u -f "%name"-"%version" ${FOLDER_ID}`
When the command... (6 Replies)
Discussion started by: Glyn_Mo
6 Replies
6. Shell Programming and Scripting
Hi All,
I have a tcsh script as:
#!/usr/bin/csh -x
set packsName=$(awk -F'' '/^execute.*=true/{print $2}' ExecutePacks.config)
for var in $packsName
do
echo "printed $var"
done
I want to assign the value which is returned by awk function to the variable called packsName.
How do I... (2 Replies)
Discussion started by: AB10
2 Replies
7. Shell Programming and Scripting
I have a code like this
v_num=9
comp_num=39
if
then
echo "pass"
fi
echo "end"
I am getting an error
ksh: v_num=99
comp_num=39
if
then
echo "pass"
fi
echo "end" (3 Replies)
Discussion started by: swayam123
3 Replies
8. UNIX for Dummies Questions & Answers
Hi I have a text file with 2 values and I am trying to assign each value to a variable and then write those to text files.
So if the textfile is data.txt with 2 values x and y
I want to assign mean=x, and stdev=y and then write these out in text files alongwith the id ($id has already been... (6 Replies)
Discussion started by: violin
6 Replies
9. Shell Programming and Scripting
Hi
I have this command, which counts number of lines in a specific file and then prints it on screen.nawk 'NF{c++}END{print "Number of GPS coordinates in file: "c}' $filename
I would like to have the output put into a variable, but can't seem to find the correct argument for it.
How do I... (3 Replies)
Discussion started by: bulleteyedk
3 Replies
10. Shell Programming and Scripting
Hi,
I'm writing a script that connects through ssh (using "expect") and then is supposed to find whether a process on that remote machine is running or not. Here's my code (user, host and password are obviously replaced with real values in actual script):
#!/usr/bin/expect
set timeout 1... (3 Replies)
Discussion started by: oseri
3 Replies
vfork(2) System Calls Manual vfork(2)
NAME
vfork - spawn new process; share virtual memory
SYNOPSIS
REMARKS
is a higher performance version of that is provided on some systems where a performance advantage can be attained.
If the calling process is multi-threaded, the newly created child process will only contain one thread. This one thread will be a copy of
the thread calling
differs from only in that the child process can share code and data with the calling process (parent process). This speeds cloning activ-
ity significantly at a risk to the integrity of the parent process if is misused.
The use of for any purpose except as a prelude to an immediate or is not supported. Any program that relies upon the differences between
and is not portable across HP-UX systems.
All HP-UX implementations must provide the entry but it is permissible for them to treat it identically to On some implementations the two
are not distinguished because the implementation is as efficient as possible. Other versions may do the same to avoid the overhead of sup-
porting two similar calls.
DESCRIPTION
can be used to create new processes without fully copying the address space of the old process. If a forked process is simply going to do
an (see exec(2)), the data space copied from the parent to the child by is not used. This is particularly inefficient in a paged environ-
ment, making particularly useful. Depending upon the size of the parent's data space, can give a significant performance improvement over
differs from in that the child borrows the parent's memory and thread of control until a call to or an exit (either by a call to or abnor-
mally (see exec(2) and exit(2)). The parent process is suspended while the child is using its resources.
returns 0 in the child's context and (later) the pid of the child in the parent's context.
can normally be used just like It does not work, however, to return while running in the child's context from the procedure which called
since the eventual return from would then return to a no longer existent stack frame.
The window begins at the call and ends when the child completes its call.
RETURN VALUE
Upon successful completion, returns a value of 0 to the child process and returns the process ID of the child process to the parent
process. Otherwise, a value of -1 is returned to the parent, no child process is created, and is set to indicate the error.
ERRORS
fails and no child process is created if any of the following conditions are encountered:
The system-wide limit on the total number of processes under execution
would be exceeded.
The system-imposed limit on the total number of processes under execution
by a single user would be exceeded.
DEPENDENCIES
Servers
Process times for the parent and child processes within the window may be inaccurate.
Parent and child processes share the same stack space within the window. If the size of the stack has been changed within this win-
dow by the child process (return from or call to a function, for example), it is likely that the parent and child processes will be
killed with signal or
In the window, a call to (see signal(2) that installs a catching function can affect handling of the signal by the parent. The par-
ent is not affected if the handling is being set to or or if is used (see sigaction(2)).
AUTHOR
was developed by the University of California, Berkeley.
SEE ALSO
exec(2), exit(2), fork(2), sigaction(2), wait(2).
vfork(2)