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
next sibling parent 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.

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
prev sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--0016e6dbe5acc700280488d5723b
Content-Type: text/plain; charset=ISO-8859-1

Graham

 Try giving an absolute path to 'mkdir'. I'm fairly sure that the exec*
 family does not use the PATH environment.


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 --0016e6dbe5acc700280488d5723b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Graham<br> <div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi= n: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-le= ft: 1ex;"><div><div class=3D"h5"><blockquote class=3D"gmail_quote" style=3D= "margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padd= ing-left: 1ex;"> Try giving an absolute path to &#39;mkdir&#39;. I&#39;m fairly sure that th= e exec*<br> family does not use the PATH environment.<br> </blockquote> <br></div></div></blockquote><div><br>I tried the different versions and us= ed execvp precisely because it&#39;s supposed to provide the path. But I ad= mit I never tried giving it an entire path.<br><br>=A0<br>BCS:<br></div> <blockquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; borde= r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div class= =3D"h5"></div></div> That&#39;s what the &#39;p&#39; in &#39;vp&#39; stand for: path.<br> <br> OTOH I don&#39;t remember if the exec&#39;s tack on the exe name to the arg= s so you might need to do:<br> <br> execvp(&quot;mkdir&quot;,[&quot;mkdir&quot;,&quot;test&quot;]);<font color= =3D"#888888"><br></font></blockquote><div><br>Because arg #0 is the name of= the exec itself?<br><br>***<br><br><br>Ok, I tried your suggestions and ob= tained some results. Right now, I can even make dmd compile some simple fil= e, like this:<br> <br>execvp(&quot;dmd&quot;, [&quot;dmd&quot;, &quot;test.d&quot;];<br><br>I= t doesn&#39;t do anything with just<br><br>execvp(&quot;dmd&quot;, [&quot;t= est.d&quot;]);<br><br>Now, my goal is to activate the dot executable from g= raphviz<br> ( <a href=3D"http://www.graphviz.org">http://www.graphviz.org</a> )<br><br>= and... it works if I use<br><br>execvp(&quot;dot&quot;, [&quot;dot&quot;,= =A0 /* arg lis */]);<br>=A0thank to you both!<br><br>strangely, it takes 22= s to produce the pdf, as opposed to about 3s at the command line...<br> I think initially, I stopped it before it could finish its work.<br><br><br=
Philippe<br></div></div>

--0016e6dbe5acc700280488d5723b--
Jun 12 2010