Thread overview
D system call
Jul 06, 2003
Andrew Edwards
Jul 06, 2003
Dario
Jul 08, 2003
Andrew Edwards
Jul 08, 2003
Dario
Jul 08, 2003
Sean L. Palmer
July 06, 2003
I have a program I would like to execute from within another! How would I accomplish this in D?

Here's the equivalent code in C++:

#include <cstdlib>
int main()
{
  std::system("some_program");
}


July 06, 2003
try this:
extern(C) int system(char*);
int main()
{
system("some_program");
return 0;
}

>I have a program I would like to execute from within another! How would I accomplish this in D?
>
>Here's the equivalent code in C++:
>
>#include <cstdlib>
>int main()
>{
>  std::system("some_program");
>}


July 08, 2003
"Dario" <Dario_member@pathlink.com> wrote...
> try this:
> extern(C) int system(char*);
> int main()
> {
> system("dmd -O scopy");
> system("scopy2.d");
> return 0;
> }

Thanks, that does the trick!

However, since I'd much rather speak my native tongue! Is there a way to say this  natively in "D"?

Andrew


July 08, 2003
>> try this:
>> extern(C) int system(char*);
>> int main()
>> {
>> system("dmd -O scopy");
>> system("scopy2.d");
>> return 0;
>> }

> Thanks, that does the trick!
>
> However, since I'd much rather speak my native tongue! Is there a way to say this  natively in "D"?
>
> Andrew

Phobos has no function to execute programs actually.
I'd like file.d to provide an execute() function beside read() and write().

Anyway, if you don't want to use the C standard library and you're running Windows you can use CreateProcess instead, but using it is very awkward.


July 08, 2003
In C world this function would be in <process.h>, not <file.h>, but perhaps execute() could alternatively take a file object instead of a pathname.

It's pretty important to have this;  depending on the OS command line syntax makes you system dependant.

Sean

"Dario" <Dario_member@pathlink.com> wrote in message news:bee9ja$2mu8$1@digitaldaemon.com...
> >> try this:
> >> extern(C) int system(char*);
> >> int main()
> >> {
> >> system("dmd -O scopy");
> >> system("scopy2.d");
> >> return 0;
> >> }
>
> > Thanks, that does the trick!
> >
> > However, since I'd much rather speak my native tongue! Is there a way to
say
> > this  natively in "D"?
> >
> > Andrew
>
> Phobos has no function to execute programs actually.
> I'd like file.d to provide an execute() function beside read() and
write().
>
> Anyway, if you don't want to use the C standard library and you're running Windows you can use CreateProcess instead, but using it is very awkward.