www.digitalmars.com         C & C++   DMDScript  

D - D system call

reply "Andrew Edwards" <edwardsac spamfreeusa.com> writes:
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");
}
Jul 06 2003
parent reply Dario <Dario_member pathlink.com> writes:
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");
}
Jul 06 2003
parent reply "Andrew Edwards" <edwardsac spamfreeusa.com> writes:
"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
Jul 07 2003
parent reply Dario <Dario_member pathlink.com> writes:
 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.
Jul 08 2003
parent "Sean L. Palmer" <palmer.sean verizon.net> writes:
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.
Jul 08 2003