www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to execute external program and process its output?

reply Marcin Kuszczak <aarti interia.pl> writes:
Hello!

I am trying to execute external command from D program, and then process its
output. spawnvp() doesn't seem to be enough as it does not return output,
but just status as int.

How to achieve it in D (I don't know method also in C(++), so even this will
help <g>)?

---
Regards
Marcin Kuszczak
(Aarti_pl)
Jul 31 2006
next sibling parent reply Pragma <ericanderton yahoo.com> writes:
Marcin Kuszczak wrote:
 Hello!
 
 I am trying to execute external command from D program, and then process its
 output. spawnvp() doesn't seem to be enough as it does not return output,
 but just status as int.
 
 How to achieve it in D (I don't know method also in C(++), so even this will
 help <g>)?
 
 ---
 Regards
 Marcin Kuszczak
 (Aarti_pl)

Marcin, I don't know the "correct" way to do this, but perhaps I can offer a short-term hack to get you by? char[] commandline = "echo 'hello world' > output.txt"; std.process.system(commandline); writefln("result: %s",std.file.read("output.txt")); Sure its not pretty, but it does work.
Jul 31 2006
parent reply Marcin Kuszczak <aarti interia.pl> writes:
Pragma wrote:

 char[] commandline = "echo 'hello world' > output.txt";
 std.process.system(commandline);
 writefln("result: %s",std.file.read("output.txt"));

I had to modify a little bit program, but then it works - thanks a lot! -- void main() { char[] commandline = "svn info >output.txt 2>&1"; std.process.system(commandline); char[] result = cast(char[])(std.file.read("output.txt")); writefln("result: %s", result); } -- In the meantime I found also that there should be functions on C API -- #include <stdio.h> FILE *popen( const char *command, const char *type); int pclose( FILE *stream); -- but as I see it is not wrapped by D. I don't have any idea how to do it. If anyone can give some more info it would be great. BTW if D wants to be also language for scripting, it should have such a possibility in standard library. -- Regards Marcin Kuszczak (Aarti_pl)
Jul 31 2006
parent reply Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
Marcin Kuszczak wrote:
 Pragma wrote:
 
 char[] commandline = "echo 'hello world' > output.txt";
 std.process.system(commandline);
 writefln("result: %s",std.file.read("output.txt"));

I had to modify a little bit program, but then it works - thanks a lot! -- void main() { char[] commandline = "svn info >output.txt 2>&1"; std.process.system(commandline); char[] result = cast(char[])(std.file.read("output.txt")); writefln("result: %s", result); } -- In the meantime I found also that there should be functions on C API -- #include <stdio.h> FILE *popen( const char *command, const char *type); int pclose( FILE *stream); -- but as I see it is not wrapped by D. I don't have any idea how to do it. If anyone can give some more info it would be great.

extern (C) { typedef void FILE; FILE* popen(char* cmd, char* type); int pclose(FILE* stream); } should work
Jul 31 2006
parent Marcin Kuszczak <aarti interia.pl> writes:
Tom S wrote:

 Marcin Kuszczak wrote:
 Pragma wrote:
 
 char[] commandline = "echo 'hello world' > output.txt";
 std.process.system(commandline);
 writefln("result: %s",std.file.read("output.txt"));

I had to modify a little bit program, but then it works - thanks a lot! -- void main() { char[] commandline = "svn info >output.txt 2>&1"; std.process.system(commandline); char[] result = cast(char[])(std.file.read("output.txt")); writefln("result: %s", result); } -- In the meantime I found also that there should be functions on C API -- #include <stdio.h> FILE *popen( const char *command, const char *type); int pclose( FILE *stream); -- but as I see it is not wrapped by D. I don't have any idea how to do it. If anyone can give some more info it would be great.

extern (C) { typedef void FILE; FILE* popen(char* cmd, char* type); int pclose(FILE* stream); } should work

Thanks! using C was easier than I thought... (Second method still does not work for me, but it is just a mater of time :-) ) -- Regards Marcin Kuszczak (Aarti_pl)
Jul 31 2006
prev sibling parent reply BCS <BCS pathlink.com> writes:
Marcin Kuszczak wrote:
 Hello!
 
 I am trying to execute external command from D program, and then process its
 output. spawnvp() doesn't seem to be enough as it does not return output,
 but just status as int.
 
 How to achieve it in D (I don't know method also in C(++), so even this will
 help <g>)?
 
 ---
 Regards
 Marcin Kuszczak
 (Aarti_pl)

IIRC somewhere back a few months ago, someone made a stream object that did just what you want. You could even write to the program's standard input by outputting to the stream.
Jul 31 2006
next sibling parent reply Marcin Kuszczak <aarti interia.pl> writes:
BCS wrote:

 Marcin Kuszczak wrote:
 Hello!
 
 I am trying to execute external command from D program, and then process
 its output. spawnvp() doesn't seem to be enough as it does not return
 output, but just status as int.
 
 How to achieve it in D (I don't know method also in C(++), so even this
 will help <g>)?
 
 ---
 Regards
 Marcin Kuszczak
 (Aarti_pl)

IIRC somewhere back a few months ago, someone made a stream object that did just what you want. You could even write to the program's standard input by outputting to the stream.

How to find it? is it somewere on Wiki? -- Regards Marcin Kuszczak (Aarti_pl)
Jul 31 2006
parent BCS <BCS pathlink.com> writes:
Marcin Kuszczak wrote:
 BCS wrote:
 
 
Marcin Kuszczak wrote:

Hello!

I am trying to execute external command from D program, and then process
its output. spawnvp() doesn't seem to be enough as it does not return
output, but just status as int.

How to achieve it in D (I don't know method also in C(++), so even this
will help <g>)?

---
Regards
Marcin Kuszczak
(Aarti_pl)

IIRC somewhere back a few months ago, someone made a stream object that did just what you want. You could even write to the program's standard input by outputting to the stream.

How to find it? is it somewere on Wiki?

These look somewhat like what I remember. http://www.digitalmars.com/d/archives/digitalmars/D/29556.html http://www.digitalmars.com/d/archives/digitalmars/D/learn/542.html
Jul 31 2006
prev sibling parent reply "Regan Heath" <regan netwin.co.nz> writes:
------------c5fnThad5n1ceLNY8yAxBF
Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
Content-Transfer-Encoding: 8bit

On Mon, 31 Jul 2006 15:53:00 -0700, BCS <BCS pathlink.com> wrote:
 Marcin Kuszczak wrote:
 Hello!
  I am trying to execute external command from D program, and then  
 process its
 output. spawnvp() doesn't seem to be enough as it does not return  
 output,
 but just status as int.
  How to achieve it in D (I don't know method also in C(++), so even  
 this will
 help <g>)?
  ---
 Regards
 Marcin Kuszczak
 (Aarti_pl)

IIRC somewhere back a few months ago, someone made a stream object that did just what you want. You could even write to the program's standard input by outputting to the stream.

Oh, me, me, pick me! Attached are the classes I wrote back then :) Let me know if you have any trouble. Regan ------------c5fnThad5n1ceLNY8yAxBF Content-Disposition: attachment; filename=process.zip Content-Type: application/zip; name=process.zip Content-Transfer-Encoding: Base64 UEsDBBQAAAAIAHEDuzRyenUYFA0AAIozAAAMAAAAcGlwZXN0cmVhbS5k3RprT+NI 8nOQ+A89kY51wJcEuP2yObTKQJi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
Jul 31 2006
parent Marcin Kuszczak <aarti interia.pl> writes:
Regan Heath wrote:

 On Mon, 31 Jul 2006 15:53:00 -0700, BCS <BCS pathlink.com> wrote:
 Marcin Kuszczak wrote:
 Hello!
  I am trying to execute external command from D program, and then
 process its
 output. spawnvp() doesn't seem to be enough as it does not return
 output,
 but just status as int.
  How to achieve it in D (I don't know method also in C(++), so even
 this will
 help <g>)?
  ---
 Regards
 Marcin Kuszczak
 (Aarti_pl)

IIRC somewhere back a few months ago, someone made a stream object that did just what you want. You could even write to the program's standard input by outputting to the stream.

Oh, me, me, pick me! Attached are the classes I wrote back then :) Let me know if you have any trouble. Regan

Thanks! I will give it a try. It would be awesome if such a class could find its way into the standard library... -- Regards Marcin Kuszczak (Aarti_pl)
Aug 01 2006