Le mar 22/06/2004 à 10:32, Juho Vuori a écrit : > Hello, > > >I want to start a console command and be able to read it's output. so i can use the output in my program. Could someone give me an example or point me in the right direction to go. is there and libs for this? (and really ... what does it call that i want to do ??? fork ?) > > > > > > popen(3) - (in case you are new to unix, run 'man 3 popen' to get info > on that) > > It creates a pipe, forks and runs a program. Calling it returns a > filedescriptor, which you can read as if it was a file (even though it > is the output of a command). You can also use it the other way around, > write to the file returned by popen() to give input to the program. But > there are some restrictions. Read the man page. A good basic stuff about > unix inter process communication is in Richard Stevens: Advanced > Programming in the Unix Environment. It's not free, you have to pay some > money for it, but is easily worth it. Using popen does not allow read/write access to the returned file descriptor. Another solution is provided by GLib: g_spawn_async_with_pipes (http://developer.gnome.org/doc/API/2.0/glib/glib-Spawning-Processes.html#g-spawn-async-with-pipes) > >Another option to my problem is that i can ping a adress to tell if it is still alive. Not by using "ping" as i want above but with code instead. even if i get an answer to this question (that would be best option i guess) I'm still interested in how to use fork (or what's it called) for other things :) > > > > > > > > You should rather use the ping-command. Even though ping seems (and is) > like a simple command, it uses raw sockets (?) that are not available > for casual users. ls -lF `which ping` shows you that ping is actually a > suid-program (run as a root user no matter who uses it) > > > Juho > > > >Thank you for helping > >Magnus > >_______________________________________________ > >gnome-devel-list mailing list > >gnome-devel-list gnome org > >http://mail.gnome.org/mailman/listinfo/gnome-devel-list > > > > > > _______________________________________________ > gnome-devel-list mailing list > gnome-devel-list gnome org > http://mail.gnome.org/mailman/listinfo/gnome-devel-list >
Attachment:
signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=