How to write a bash script to do the following tasks?
- From: yangliang_mr@xxxxxxxxxxx
- Date: 22 Oct 2006 14:19:10 -0700
Hi,
I need to run a server program (SVR) on machine A and a client program
(CLI) on machine B. To set up a connection between SVR and CLI, the
following command must be issued on machine B:
$CLI -connect A -name link1
After the connection is set up between A and B, the Client program will
show a message -- "Connection is set up" on the screen. Then I will let
the server program do some real work on machine A (no external input
needs to be taken for the client program during this process on machine
B).
I need to set up many connections between A and B, i.e. I have to spawn
multiple instances of the client program. The server can only take one
connection request from the client program at one time, otherwise the
server program will refuse to work (i.e. connection requests has to be
sent out sequentially on machine B).
I'm trying to run the following bash script file on B (server program
is always running on A):
CLI -connect A -name link1 &
CLI -connect A -name link2 &
CLI -connect A -name link3 &
CLI -connect A -name link4 &
....
CLI -connect A -name link100 &
I got two problems:
Problem1: How to simulate the action pressing ENTER key in the bash
script file?
Explanation: even though I append & to each command line in the script
file, the task is not put into background automatically after the first
connection is set up. This is because the shell does not get the
control back from the client program and thus all the following command
lines do not get a chance to execute. I have to press ENTER key when
the message "Connection is set up" shows up. To confirm this, I
type the single command line "CLI -connect A -name link1 &" in
the shell and got the same thing (shell prompt does not come back
immediately unless I press ENTER key after the message "Connection is
set up" shows up on the screen)
Problem2: How to spawn the client program both in background and
sequentially?
Explanation: As the connection request has to be issued sequentially,
if I put all those tasks into background, I can not control the
sequence of connection request from so many client programs to the
server program. I try to put the semicolon before or after & to force
those tasks to run one by one. But the shell complains about the
combination use of semicolon (;) and background task symbol (&).
Can anyone help me solve this issue?
Thanks,
Liang
.
- Follow-Ups:
- Re: How to write a bash script to do the following tasks?
- From: Steve Ackman
- Re: How to write a bash script to do the following tasks?
- Prev by Date: Re: Need Boot Manager for Linux/Windows XP
- Next by Date: Stats alt.os.linux (last 7 days)
- Previous by thread: problem with characters in filenames - konqueror?
- Next by thread: Re: How to write a bash script to do the following tasks?
- Index(es):
Relevant Pages
|