Sponsored Content
Top Forums Shell Programming and Scripting Breaking "while read" also breaks the parent process Post 302437740 by chebarbudo on Friday 16th of July 2010 04:13:14 AM
Old 07-16-2010
Question Breaking "while read" also breaks the parent process

Hi,

I'm a bit confused. Maybe some master can explain to me what is happening.

I have a program that starts issuing output about himself loading.
I want to run it in another thread but I want to wait untill it's fully loaded.

Program sample:
Code:
$ cat myprogram
echo "loading"
echo "almost ready"
echo "up and running"
while true; do
    echo "I don't care about the rest of the output"
    sleep 1
done

If I run it like this, it will stay in another thread but I will not be sure it is "up and running":
Code:
$ myprogram &

So I tried to run it like this but the process dies very soon :
Code:
$ myprogram | while read -r; do
    [[ "$REPLY" == "up and running" ]] && break
done
echo "Now I know myprogram went all the way untill it is up and running"
echo "But now myprogram is dead :-("

Question: How can I stat myprogram and wait untill it outputs "up and running"?

Thanks for your help.
Santiago
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to request a "read" or "delivered" receipt for mails

Dears, I've written a script which allows me to send mails in different formats with different attaches. Now I still want to add a feature to this script. My users would like to be able to receive a "read" or "delivered" receipt for their mails. The script send mails on behalve of an specific... (1 Reply)
Discussion started by: plelie2
1 Replies

2. Shell Programming and Scripting

Breaking input with "read" command

In this post, Perderabo's script says echo 05/06/25 14:15:56 | IFS=" /:" read Y1 M1 D1 h1 m1 s1 which, if I am not wrong, will break the input into Y1, M1 et al. I tried the following in my code #! /bin/ksh # per.sh typeset -R2 HOUR=00 typeset -R2 MIN=00 typeset -R2 SEC=00 ... (2 Replies)
Discussion started by: vino
2 Replies

3. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

4. Red Hat

"service" , "process" and " daemon" ?

Friends , Anybody plz tell me what is the basic difference between "service" , "process" and " daemon" ? Waiting for kind reply .. .. (1 Reply)
Discussion started by: shipon_97
1 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Purpose of "read" and "$END$" in ksh ?

Hi, Could anyone please shed some light on the following script lines and what is it doing as it was written by an ex-administrator? cat $AMS/version|read a b verno d DBVer=$(/usr/bin/printf "%7s" $verno) I checked that the cat $AMS/version command returns following output: ... (10 Replies)
Discussion started by: dbadmin100
10 Replies

7. Shell Programming and Scripting

Read from "list1" and list matches in "list2"

I want to print any matching IP addresse in List1 with List 2; List 1 List of IP addresses; 161.85.58.210 250.57.15.129 217.23.162.249 74.76.129.101 30.221.177.237 3.147.200.59 170.58.142.64 127.65.109.33 150.167.242.146 223.3.20.186 25.181.180.99 2.55.199.32 (3 Replies)
Discussion started by: lewk
3 Replies

8. Shell Programming and Scripting

While loop breaking when using "ssh" command inside

Hi , I am trying to read a list of hosts from a config file and trying to get file list from that host. For this I have used one while loop. cat "$ARCHIVE_CFG_FILE" | sed '/^$/d' | sed '/^#/d' | while read ARCHIVE_CFG do SOURCE_SERVER_NAME=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print... (2 Replies)
Discussion started by: Anupam_Halder
2 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies
HWLOC-PS(1)							       hwloc							       HWLOC-PS(1)

NAME
hwloc-ps - List currently-running processes or threads that are bound SYNOPSIS
hwloc-ps [options] OPTIONS
-a list all processes, even those that are not bound to any specific part of the machine. -p --physical report OS/physical indexes instead of logical indexes -l --logical report logical indexes instead of physical/OS indexes (default) -c --cpuset show process bindings as cpusets instead of objects. -t --threads show threads inside processes. If -a is given as well, list all threads within each process. Otherwise, show all threads inside each process where at least one thread is bound. --whole-system Do not consider administration limitations. --pid-cmd <cmd> Append the output of the given command to each PID line. For each displayed process ID, execute the command <cmd> <pid> and append the first line of its output to the regular hwloc-ps line. DESCRIPTION
By default, hwloc-ps lists only those currently-running processes that are bound. If -t is given, processes that are not bound but contain at least one bound thread are also displayed, as well as all their threads. hwloc-ps displays process identifier, command-line and binding. The binding may be reported as objects or cpusets. By default, process bindings are restricted to the currently available topology. If some processes are bound to processors that are not available to the current process, they are ignored unless --whole-system is given. The output is a plain list. If you wish to annotate the hierarchical topology with processes so as to see how they are actual distributed on the machine, you might want to use lstopo --ps instead (which also only shows processes that are bound). The -a switch can be used to show all processes, if desired. EXAMPLES
If a process is bound, it appears in the default output: $ utils/hwloc-ps 4759 Core:0 myprogram If a process is not bound but 3 of his 4 threads are bound, it only appears in the thread-aware output: $ utils/hwloc-ps $ utils/hwloc-ps -t 4759 Machine:0 myprogram 4759 Machine:0 4761 PU:0 4762 PU:2 4765 PU:1 To display the binding of already running MPI processes (launched by Open MPI) and append their MPI rank (in MPI_COMM_WORLD) to each line: $ utils/hwloc-ps --pid-cmd myscript 29093 L1dCache:0 myprogram OMPI_COMM_WORLD_RANK=0 29094 L1dCache:2 myprogram OMPI_COMM_WORLD_RANK=1 29095 L1dCache:1 myprogram OMPI_COMM_WORLD_RANK=2 29096 L1dCache:3 myprogram OMPI_COMM_WORLD_RANK=3 where myscript is a bash script doing: #!/bin/sh cat /proc/$1/environ 2>/dev/null | xargs --null --max-args=1 echo | grep OMPI_COMM_WORLD_RANK SEE ALSO
hwloc(7), lstopo(1), hwloc-calc(1), hwloc-distrib(1) 1.7 Apr 07, 2013 HWLOC-PS(1)
All times are GMT -4. The time now is 09:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy