Re: [Vala] read a program stdout



Hello,

                في ر، 23-11-2011 عند 15:08 -0200 ، كتب Rodrigo Herefeld:
Hi all!
I need to run a program and get the stdout data from it, for example, im
python i would
do:
import os
print(os.popen("gpg --version").read()

in vala i've tryed:

var ret = Posix.FILE.popen("gpg --version","r+");
string tmpret = "";
ret.scanf("%s",tmpret);

You probably want "out tmpret" here. Take a look at GLib.Process
(especially spawn_command_line_sync), it may be an easier way to do what
you want. http://valadoc.org/glib-2.0/GLib.Process.html

HTH,
Abderrahim




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]