Hiding child when called in background


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Hiding child when called in background
# 1  
Old 09-17-2013
Hiding child when called in background

Hi,
I have 2 scripts, one of which is calling the other in background. I want only the output of the parent script on the
output
Code:
 
parent.ksh 
#!/bin/ksh
set -x
echo "Calling child."
. ./child.ksh & > /dev/null
track_pid=`echo $!`
echo "Child kicked off in the background."
sleep 20
kill -9 $track_pid
echo "Child killed"

Code:
 
child.ksh
#!/bin/ksh
#set -x
while [ 1 -eq 1 ]
do
echo "Child is running"
sleep 5
done

Code:
 
>parent.ksh
Calling child.
Child is running
Child kicked off in the background.
Child is running
Child is running
Child is running
Child Killed

When the parent is executed, I dont want to see the child (which is runing at the background) echo output.
What should be done on the parent script to make the output as below
Code:
 
Calling child.
Child kicked off in the background.
Child Killed

# 2  
Old 09-17-2013
Try:
Code:
(./child.ksh >/dev/null) &

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 09-17-2013
Quote:
Originally Posted by Scrutinizer
Try:
Code:
(./child.ksh >/dev/null) &

yes its working ...thanks
# 4  
Old 09-17-2013
Don't source the file child.ksh, but execute it (i.e. remove the first dot in the line). Needs to be chmoded to executable, then.
# 5  
Old 09-17-2013
That is right, you can leave out the parentheses..

Code:
./child.ksh >/dev/null &

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Issue with tracking successful completion of Child process running in background

Hello All, I am using Linux. I have two scripts: inner_script.ksh main_wrapper_calling_inner.ksh Below is the code snippet of the main_wrapper_calling_inner.ksh: #!/bin/ksh ppids=() ---> Main array for process ids. fppids=() ---> array to capture failed process ids. pcnt=0 --->... (5 Replies)
Discussion started by: dmukherjee
5 Replies

2. 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

3. 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

4. Programming

C++ overriding Vs hiding

class B { public: void fns(void){//base def;} }; class D:public B { public: void fns(void) {//new def;} }; I was thinking the above is overriding but somewhere else i found the above is just hiding.Only virtual functions can be considered as overriding? This is the exact statement ... (1 Reply)
Discussion started by: johnbach
1 Replies

5. UNIX for Dummies Questions & Answers

Hiding Password

Hello. A bit of a puzzle here: I have a 3rd party executable, which requires the following parameters: parm1 = program_name, parm2=userid/password, parm3=additional flags. We tried passing password as a variable, but you can do grep, and see what the password actually is I found a bit... (2 Replies)
Discussion started by: Kishinevetz
2 Replies

6. Shell Programming and Scripting

Hiding the Directory

Hi, I have a directory i want to just hide this directory. Could you please tell me the command to hide directory. (2 Replies)
Discussion started by: shivanete
2 Replies

7. Shell Programming and Scripting

How to export a variable from a child process running in background to the parent

Hi All, I have a script which calls a child script with a parameter to be run in the background . childscript.ksh $a & Can any one suggest me how do i export a variable from the child script to parent script? Note that the child script is in background If the child script is in... (3 Replies)
Discussion started by: aixjadoo
3 Replies

8. UNIX for Advanced & Expert Users

how to make a parent wait on a child shells running in background?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (1 Reply)
Discussion started by: albertashish
1 Replies

9. Programming

display in a child process a command called in the parent one

Hi , Could you tell me if I am right 1. Using fork(), pipe(), execlp() and dup() (see man 2 dup), write a C program executing the command ps -j in a parent process, displaying the result in a child process. #include <unistd.h> #include <errno.h> #include <stdio.h> #include <unistd.h>... (7 Replies)
Discussion started by: remid1985
7 Replies

10. Shell Programming and Scripting

Hiding password from ps

I'm calling a program with a command line arguement containing a password. while the process is running anyone on the system can ps -ef and see the password. Is there a way to prevent this from happening. example PROGRAM USERNAME/PASSWD I've also tried PROGRAM `cat passfile` ... (7 Replies)
Discussion started by: sudojo
7 Replies
Login or Register to Ask a Question