Zenity progress dialog and child processes

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
marmistrz

Zenity progress dialog and child processes

Post by marmistrz »

Let's assume we have a bash script `bash.sh` and a python script `python.py`. The python script can't be modified. (Say, upstream)

`bash.sh` is a zenity wrapper script which creates the gui. `python.py` calls wget somewhere at the end.

In `bash.sh` there's `python.py` called and a zenity progress bar displayed, like this

Code: Select all

./python.py | zenity --progress --pulsate --auto-close
So the calls are: `bash.sh` => `python.py` => `wget`

If I click "cancel" before the wget download begins, it is canceled and the `python.py` script exits, like this:

Code: Select all

Traceback (most recent call last):
File "python.py", line 41, in <module>
print(s.encode('utf-8')) IOError: [Errno 32] Broken pipe
But if the wget download starts, clicking "cancel" does absolutely nothing. The progress dialog stays open, nothing is closed.

What should I do, so that the "cancel" button stops the wget download?

Thanks
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
DrHu

Re: Zenity progress dialog and child processes

Post by DrHu »

http://manpages.ubuntu.com/manpages/luc ... get.1.html
  • DESCRIPTION
    GNU Wget is a free utility for non-interactive download of files from
    the Web. It supports HTTP, HTTPS, and FTP protocols, as well as
    retrieval through HTTP proxies.

    Wget is non-interactive, meaning that it can work in the background,
    while the user is not logged on. This allows you to start a retrieval
    and disconnect from the system, letting Wget finish the work. By
    contrast, most of the Web browsers require constant user’s presence,
    which can be a great hindrance when transferring a lot of data.
If it was the only app you needed to be running at that time, you could crash your desktop Ctrl+alt+del (assuming you did enabled that service to be running: Ubuntu at some point stopped emnabling it as a default method, apparently it seemed to confuse some users (they said!..))

Or you could manipulate wget options to enable you to kill the process..
http://superuser.com/questions/515313/f ... et-timeout
http://www.cyberciti.biz/faq/kill-process-ubuntu/
marmistrz

Re: Zenity progress dialog and child processes

Post by marmistrz »

The problem is that the zenity progress dialog doesn't quit because there's still wget output.

/edit: here's the script: http://marmistrz.net63.net/public/zenity/
The python one has the name mipla.py instead. In the first dialog you should type a number. To be on the safe side, just type 100
Locked

Return to “Scripts & Bash”