Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I try to start processes by script, which can interact.

EDIT: The general issue is to start these processes via php. After the process is started, another php-script (or the same running again) shall read the output of the process. Than a third php-script shall write to the input of the process. To simulate the start by php I did use a bash-script, because it has the same problems.

For this, I create an out-file, the process can write to, and a fifo, the process reads from. My process is, eg, passwd.

When I try it like this:

passwd > 2> < & echo $!

it does not work. According to this posting a EOF causes termination of the passwd-Process.

Following the solution of the mentioned posting, I tried

cat > &
passwd > 2> < & echo $!

which creates two jobs which I can watch with


My target is, to start this via bash-script

cat > & PID=$!
echo $PID

When I do call the script, a Process with PID = $PID is created, but not a job. And, much more important,

passwd > 2> < & echo $!

does not work, because again an EOF is send through the pipe.

How can I keep the pipe open from a script?

share|improve this question

I suggest using Tcl's "expect" library for this, especially for scripting passwd; it allocates a pseudo-terminal which removes most of the suprises, and lets you take action based on the results.

share|improve this answer
Well, I already had a look at expect. It does read from anywhere, too, doesn't it? So I would have to open a pipe for expect with the same issues – kvogelsa Jul 18 '12 at 13:32
I don't follow what you're saying; run expect at the top level and have it send data to the process, it handles all the pipe machinery for you. What, ultimately, are you trying to do? – pjc50 Jul 18 '12 at 16:12
I edited the post to explain my target. – kvogelsa Jul 19 '12 at 9:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.