Click to See Complete Forum and Search --> : GUI and std output
portablevcb
01-29-2002, 01:51 PM
I am programming GUI front end for a command line program (cdrdao in this case, but, I do others as well).
How do I get the command line program output into the GUI? For example, when the cmd line program outputs a "10% complete" I want to update a status bar in the GUI. Redirecting to a file doesn't work and piping doesn't seem to work. They both want to update the GUI AFTER the cmd line program is complete, not during execution.
Thanks.
portablevcb
02-05-2002, 06:10 PM
Since no one responded to this I assume:
1) It was a stupid question
2) It wasn't worded correctly
3) It is too hard to do
Just wondered which one is correct.
Strike
02-05-2002, 07:37 PM
I just don't know how to do it. Maybe you should look at the source for other similar front-ends?
EscapeCharacter
02-05-2002, 08:19 PM
as far as i know most frontends dont just get the output from the command line app, they actually use the routines in the apps themselves and instead of outputing the data to stdout it goes into some variable that the gui app uses
[ 05 February 2002: Message edited by: EscapeCharacter ]
Strogian
02-05-2002, 10:47 PM
Well, I'm not sure exactly what you're doing, but that may just be because I've never done it before. :) Are you just trying something like "cdrdao | myfrontend"? Or "cdrdao > temp.dat & ; myfrontend"?
binaryDigit
02-06-2002, 02:15 AM
what about forking it?
you can run execv (or something similar)
in one pid and read from stdout in the original process.
that's a real shot in the dark, but....
portablevcb
02-07-2002, 09:51 AM
Wow!
Thanks for the support. This always is a good spot to go for excellent help.
I had not tried forking. Probably because a) I have never used it before and b) because I did not think of it.
I had tried the pipes (both > and | ) and they do not execute until after the parent process is complete. For those of you who just want to be notified when the parent process is complete and to view the results, these both work fine, just route the output into a file, open the file and put the results into the GUI window. I will post a source code if anyone is interested.
FWIW, other front end source code I looked at make direct calls to the processes, something I was trying to avoid. Just lazy. I guess I may as well jump in with both feet instead of just wetting my little toe.
binaryDigit: Is this phillip?
binaryDigit
02-07-2002, 08:43 PM
yeah. it's me :)
i went ahead and tried to write something with the fork, but no luck.
i don't know enough about forking a process, but in the code i tried it on the same problem occured that you see in a pipe. unless someone here understands more about this? i'm out of ideas. sorry
portablevcb
02-08-2002, 09:51 AM
That's justice for you. 25 years of programming experience in 5 computer languages (not counting assembler variations), and it still takes a young mind to come up with new ways to do things. :rolleyes:
BTW, I looked at the gtoaster code and they have a combination of pipes and forks, depending on the program called.
Thanks for the replies everyone. I recommend looking at the gtoaster source code if you ever want to do something like this, the piping.c and record.c routines have everything you might need.