Sponsored Content
Top Forums Shell Programming and Scripting 36 Child Processes not running as desired Post 302405050 by nthiruvenkatam on Thursday 18th of March 2010 12:41:10 AM
Old 03-18-2010
Code:
root@Sam104 # cat Parent.sh 
#!/bin/bash
INDEX=0
INDEX1=1
INDEX2=2
for line in `cat NODES.txt`;
do
        array[$INDEX]=$(pwd)"/"$line"/"
        array[$INDEX1]=$(echo $line | tr "[:upper:]" "[:lower:]") 
        array[$INDEX2]=$line
        mkdir "${array[$INDEX2]}"
        echo "admin tech-support ftp://root:5620Sam!@172.16.10.10"$(pwd)"/"${array[$INDEX2]}"/"${array[$INDEX1]} > $(pwd)"/"${array[$INDEX2]}"/"Script
        ./Child.sh ${array[$INDEX]} ${array[$INDEX1]} ${array[$INDEX2]} &
        INDEX=`expr $INDEX + 3`
        INDEX1=`expr $INDEX1 + 3`
        INDEX2=`expr $INDEX2 + 3`
done
root@Sam104 # 




root@Sam104 # cat Child.sh 
#!/bin/bash
i=1
j=1
while [ $i = 1 ]
do
        file_exist=$(ls -l $1 | grep $2)
        length=${#file_exist}
        size=$(ls -l $1 | grep $2 | awk '{ print $5 }')
        echo "$1    $2    $length    NE's CRON scheduler: Not yet started"
        if [ $length != 0 ]
        then
                new_file_name=`date +%d%m%y%H%M%S`
                echo "NE's CRON scheduler: Started"
                echo "Dumping the TS File . . ."
                k=1
                while [ $k != 2000 ]
                do
                        present_size=$(ls -l $1 | grep $2 | awk '{ print $5 }')                 
                        if [ $size = $present_size ]
                        then
                                k=`expr $k + 1`
                        else
                                j=`expr $j + 1`
                                size=$present_size
                        fi
                done    
                j=1
                cpy_status=$(cp $1$2 $1$3"_"$new_file_name)
                delete_status=$(rm $1$2)
                echo "File Details:- File Name: $3"_"$new_file_name File Size: $present_size"
                sleep 5
        fi
done

root@Sam104 #


Last edited by pludi; 03-18-2010 at 03:45 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

what are parent and child processes all about?

I don't follow what these are... this is what my text says... "When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)
Discussion started by: xyyz
1 Replies

2. Programming

Controlling child processes

Hello all, I am trying to create n child processes and control them from a parent process; say make child 3 print its pid and then child 5 do the same and some other stuff. Is there a way to accomplishing this after all the child processes are created via a call to fork(). Thank you, FG (23 Replies)
Discussion started by: forumGuy
23 Replies

3. Shell Programming and Scripting

Parent/Child Processes

Hello. I have a global function name func1() that I am sourcing in from script A. I call the function from script B. Is there a way to find out which script called func1() dynamically so that the func1() can report it in the event there are errors? Thanks (2 Replies)
Discussion started by: yoi2hot4ya
2 Replies

4. Programming

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Discussion started by: green_dot
0 Replies

5. Shell Programming and Scripting

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n",... (1 Reply)
Discussion started by: green_dot
1 Replies

6. UNIX for Advanced & Expert Users

killing all child processes

Hi, Is there a way I can kill all the child processes of a process, given its process id. Many thanks in advance. J. (1 Reply)
Discussion started by: superuser84
1 Replies

7. Programming

How to limit the number of child processes

I need a mechanism to fork child processes and all child processes should connect to a server.but the number of child processes should be limited(for ex:50) Here's my pseudo, but I cant figure out how to limit the child process number. Should I use a semaphore? or what? for(;;)... (3 Replies)
Discussion started by: xyzt
3 Replies

8. Shell Programming and Scripting

A script that kills previous instances of itself upon running not killing child processes

I'm likely going to explain this clumsily, so apologies in advance: I have the following script: #!/bin/bash pidPrefix="logGen" checkPrime () { if /sbin/ifconfig eth0:0|/bin/grep -wq inet;then isPrime=1;else isPrime=0;fi } killScript () { /usr/bin/find /var/run -name... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

9. Shell Programming and Scripting

Controlling the Number of Child processes

I am trying to implement the below using Ksh script on a Lx machine. There is a file(input_file) with 100K records. For each of these records, certain script(process_rec) needs to be called with the record as input. Sequential processing is time-consuming and parallel processing would eat up... (2 Replies)
Discussion started by: APT_3009
2 Replies

10. Shell Programming and Scripting

Get all child processes of a process

is there a universal way of getting the children of a particular process? i'm looking for a solution that works across different OSes...linux, aix, sunos, hpux. i did a search online and i kept finding answers that were specific to Linux..i.e. pstree. i want to be able to specify a process... (2 Replies)
Discussion started by: SkySmart
2 Replies
IN_ARRAY(3)								 1							       IN_ARRAY(3)

in_array - Checks if a value exists in an array

SYNOPSIS
bool in_array FALSE (mixed $needle, array $haystack, [bool $strict]) DESCRIPTION
Searches $haystack for $needle using loose comparison unless $strict is set. PARAMETERS
o $needle - The searched value. Note If $needle is a string, the comparison is done in a case-sensitive manner. o $haystack - The array. o $strict - If the third parameter $strict is set to TRUE then the in_array(3) function will also check the types of the $needle in the $haystack. RETURN VALUES
Returns TRUE if $needle is found in the array, FALSE otherwise. EXAMPLES
Example #1 in_array(3) example <?php $os = array("Mac", "NT", "Irix", "Linux"); if (in_array("Irix", $os)) { echo "Got Irix"; } if (in_array("mac", $os)) { echo "Got mac"; } ?> The second condition fails because in_array(3) is case-sensitive, so the program above will display: Got Irix Example #2 in_array(3) with strict example <?php $a = array('1.10', 12.4, 1.13); if (in_array('12.4', $a, true)) { echo "'12.4' found with strict check "; } if (in_array(1.13, $a, true)) { echo "1.13 found with strict check "; } ?> The above example will output: 1.13 found with strict check Example #3 in_array(3) with an array as needle <?php $a = array(array('p', 'h'), array('p', 'r'), 'o'); if (in_array(array('p', 'h'), $a)) { echo "'ph' was found "; } if (in_array(array('f', 'i'), $a)) { echo "'fi' was found "; } if (in_array('o', $a)) { echo "'o' was found "; } ?> The above example will output: 'o' was found SEE ALSO
array_search(3), isset(3), array_key_exists(3). PHP Documentation Group IN_ARRAY(3)
All times are GMT -4. The time now is 03:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy