Re: Starting an process ? or ping with code
- From: Juho Vuori <juho vuori kepa fi>
- To: Magnus Wirström <asdlinux yahoo se>
- Cc: Gnome Developer list <gnome-devel-list gnome org>
- Subject: Re: Starting an process ? or ping with code
- Date: Tue, 22 Jun 2004 11:32:23 +0300
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.
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]