www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - using std.process

reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
OK, this is a real newbie question:

How can I use std.process?

when I do:

import std.process;

void main() {
    execvp("mkdir", ["test"]);
}

nothing happens.

What am I doing wrong?
I'm on Vista there, didn't try the equivalent under Linux.


Philippe
Jun 11 2010
parent reply Graham Fawcett <fawcett uwindsor.ca> writes:
On Fri, 11 Jun 2010 19:09:04 +0000, Philippe Sigaud wrote:

 OK, this is a real newbie question:
 
 How can I use std.process?
 
 when I do:
 
 import std.process;
 
 void main() {
     execvp("mkdir", ["test"]);
 }
 
 nothing happens.
 
 What am I doing wrong?
 I'm on Vista there, didn't try the equivalent under Linux.
Try giving an absolute path to 'mkdir'. I'm fairly sure that the exec* family does not use the PATH environment. Best, Graham
Jun 11 2010
parent reply BCS <none anon.com> writes:
Hello Graham,

 On Fri, 11 Jun 2010 19:09:04 +0000, Philippe Sigaud wrote:
 
 OK, this is a real newbie question:
 
 How can I use std.process?
 
 when I do:
 
 import std.process;
 
 void main() {
 execvp("mkdir", ["test"]);
 }
 nothing happens.
 
 What am I doing wrong?
 I'm on Vista there, didn't try the equivalent under Linux.
Try giving an absolute path to 'mkdir'. I'm fairly sure that the exec* family does not use the PATH environment.
That's what the 'p' in 'vp' stand for: path. OTOH I don't remember if the exec's tack on the exe name to the args so you might need to do: execvp("mkdir",["mkdir","test"]); -- ... <IXOYE><
Jun 11 2010
parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
Graham

 Try giving an absolute path to 'mkdir'. I'm fairly sure that the exec*
 family does not use the PATH environment.
I tried the different versions and used execvp precisely because it's supposed to provide the path. But I admit I never tried giving it an entire path. BCS:
 That's what the 'p' in 'vp' stand for: path.

 OTOH I don't remember if the exec's tack on the exe name to the args so you
 might need to do:

 execvp("mkdir",["mkdir","test"]);
Because arg #0 is the name of the exec itself? *** Ok, I tried your suggestions and obtained some results. Right now, I can even make dmd compile some simple file, like this: execvp("dmd", ["dmd", "test.d"]; It doesn't do anything with just execvp("dmd", ["test.d"]); Now, my goal is to activate the dot executable from graphviz ( http://www.graphviz.org ) and... it works if I use execvp("dot", ["dot", /* arg lis */]); thank to you both! strangely, it takes 22s to produce the pdf, as opposed to about 3s at the command line... I think initially, I stopped it before it could finish its work. Philippe
Jun 12 2010