3

I wrote this little script:

response=$(process ...) | zenity --progress --pulsate
echo $response

I want read the response of the process, whatever it is, and show a pulsating progress bar in the meanwhile. The problem is that I don't read any response at the end. I think because all the output from the previous process is sent to zenity.

  • 1
    Um, no, this is wrong. You assign something to the variable $response and then pipe this assignment to zenity. – January Jul 4 '13 at 12:19
  • Yes, I know was wrong. Unfortunately I didn't know the command "tee"... I'm going to try it now! – nunzio13n Jul 4 '13 at 17:44
2

Um, no, this is wrong. You assign something to the variable $response and then pipe this assignment to zenity. Try

process | tee /tmp/response.txt | zenity --progress --pulsate --auto-close
response=$( cat /tmp/response.txt )

That way, the output will be stored in the file /tmp/response.txt, which you can later read into a variable.

1

I had the same problem and didn't want to create a temp file, so my solution was:

#!/bin/bash
FIFO=$(mktemp -u)
mkfifo $FIFO
(cat $FIFO | zenity --progress --pulsate --auto-close) &

response=$(process)

echo 'Bye bye' > $FIFO
rm -f $FIFO

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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