Interacting with two BASH shells

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Interacting with two BASH shells
# 1  
Old 08-08-2009
Interacting with two BASH shells

Hi. I'm working with two BASH shells in order to perform two tasks. For simplicity, suppose that at Shell #1 I'm executing this program:
sleep 100

whose PID is 263. Meanwhile Shell #2 is waiting for its termination to follow with a second one.

I tried with:
wait 263
# Script for second task...

at Shell #2, but it throws me this message:
-bash: wait: pid 263 is not a child of this shell

Any idea of how to perform this operation?

Many thanks in advance.
# 2  
Old 08-08-2009
Wouldn't it be easier to run your (first) script in the background and keep an eye on the - foregrounded - process table of the (only) shell ...

[house@leonov] sh test.bash &
[house@leonov] ps aux | grep 'sh' | grep 'test'
house   27118   11400   1588   pts/3   sh test.bash

# 3  
Old 08-08-2009
Thanks for the reply. In this case I have to work on two shells, since I'm running OpenSees and Matlab at the same time.

What I need is to emulate the "wait" command in order to perform my request.

Thanks in advance.
# 4  
Old 08-08-2009

You could try something like this:

while [ "$(ps -ef | awk '$2 == '${1:-X})" ]; do sleep 3; done

Pass in the process ID to wait for (i.e. "myWait 5657" or "./myWait 5657")
# 5  
Old 08-08-2009
Many thanks for the reply. Yes, my first try was:
while [ "$(ps c | grep 263)" ]; do sleep 1; done

But I would like to see a better solution, like the wait command. Smilie

Thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to call exeute multiple bash shells from one master shell?

I have few bash shells, which i want to run sequentially, how to create a shell file, and execute/call one after other shell file. I am very new to shell programming. Bult some and running individually and also with crontab scheduler. never had a shell calling other shells, kindly would like... (2 Replies)
Discussion started by: cplusplus1
2 Replies

2. UNIX for Dummies Questions & Answers

Please what are shells?

I mean like this: Can anyone explain how this works? I hope my post is not spam. I think its related to linux. Thank you (1 Reply)
Discussion started by: postcd
1 Replies

3. Shell Programming and Scripting

Code for count the frequency of interacting pairs

Hi all, I am trying to analyze my data, and I will need your experience. I have some files with the below format: res1 = TYR res2 = ASN res1 = ASP res2 = SER res1 = TYR res2 = ASN res1 = THR res2 = LYS res1 = THR res2 = TYR etc (many lines) I am... (3 Replies)
Discussion started by: Tzole
3 Replies

4. Shell Programming and Scripting

Scrolling through text while interacting with program prompts

Hi all, I am trying write a shell script to automate the installation of a program, but during the process of the installation, the installation program requires the user to scroll through 10 pages of a license agreement. Since this is coming from stdout and is not a prompt, I am unable to send... (4 Replies)
Discussion started by: nanlee
4 Replies

5. UNIX for Dummies Questions & Answers


Lets say my default shell is bash and then i load up csh and then ksh. How would i exit csh without exiting ksh? so basically i gone from bash > csh > ksh and i wish to close csh (2 Replies)
Discussion started by: Bill Thompson
2 Replies

6. UNIX for Dummies Questions & Answers

Differences in BASH and ASH shells regarding if command?

Guys I now have a script that's working in a BASH environment, however one line doesn't appear to be working on an embedded device that has a busybox therefore ASH shell. I've googled but there's very little I can find regarding the ASH shell. In BASH the following line works... if ] ;... (6 Replies)
Discussion started by: Bashingaway
6 Replies

7. Shell Programming and Scripting

Bash shells communication

Hello all, I have the following problem. In a Bash shell I run a program (I don't have the source code) which will execute some steps. At every step the program will wait for a user input. So I would like that another script which is running on a different shell will send these input togheter with... (4 Replies)
Discussion started by: alohisius
4 Replies

8. Shell Programming and Scripting

supply password to scp with out interacting

Hi, I am trying to supply password to scp with out having manual interaction. Like, store the password in a variable and it should be supplied to the scp when it prompted for the password. Is there any other way than the user authentication and using "expect" in perl script. i.e is this... (3 Replies)
Discussion started by: pc_raghu
3 Replies

9. Answers to Frequently Asked Questions

Difference between ksh,bash and different shells.

Hello Everyone, Can someone please tell me the key difference between the different shells availabe i.e. ksh,bash,(i don't know the others ones. :confused: (5 Replies)
Discussion started by: a25khan
5 Replies

10. BSD

BSD, Bash and Shells?

When I use Mac OS X's Terminal the UI is some what easier than that of Linux... I this just a shell or something because using Bash is a pain in RH's Linux 9. It's so sensitive about case etc. ??? In that way what is the shell that OS X uses as it's default Bash is on OS X (OK Duh) and... (3 Replies)
Discussion started by: RedVenim
3 Replies
Login or Register to Ask a Question