Posted: Mon Aug 25, 2008 11:13 am Post subject: GTK2-Perl -> Bash subprocesses
Hi,
I'm new to both GTK+ and Perl and I'm writing my first little application. My application currently displays a few windows and dialogs but nothing advanced. At one point in my application however I need to handle subprocesses (I think anyway).
I have an expect script which is used to flash the firmware on a connected device. Basically my app polls the DHCP server, gets a list of IP addresses and will then run the expect script on each IP. I'd like to make this somewhat graphical, but I'm not sure what I need to do this.
For each IP address I want to create a small dialog window with a progress bar (or maybe just a label), and a textview. I want the textview to constantly append the text outputted from the expect script. So, say there are 5 connected devices, 5 dialogs would open with debug info from each Flash appended (the expect script prints out the debug info).
Now what I'm not so sure of is how should I go about doing this (which classes etc.)? I don't need any code, but pseudo code would be a big help :)
Currently, what I think need to do is:
Code: (Plaintext)
1 2 3 4 5 6 7 8
foreach IP address
create a new dialog
execute expect script
??? somehow update textview / progress bar ???
wait to be closed by user
end foreach
However updating the textview and running the expect script in the background is where I am currently stumped. Any help on this would be really appreciated.
I'm guessing you should run the expect script with a shell script that will pipe stderr into a fifo. That way you can just use "exec" and not have to worry, if you set up an open read on the fifo. You may need some flush functions from IO::Handle for this...or not.
I'm learning gtk in C, but I've done a fair bit of perl/tk, and if there is any connection there may be a buffering issue on the GUI end too -- perl may wait for a lot more than one line before it updates the textview. The tk command is actually update.