Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 16, 2012 How to call external program in D | ||||
---|---|---|---|---|
| ||||
I am new to D. Can you please tell, how to call external program in D. Example: in C, one can do this: http://stackoverflow.com/questions/43116/how-can-i-run-an-external-program-from-c-and-parse-its-output I want to call an external program (e.g. ls or date) in D. Thanks |
November 16, 2012 Re: How to call external program in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sparsh Mittal | On Friday, 16 November 2012 at 19:15:09 UTC, Sparsh Mittal wrote: > I want to call an external program (e.g. ls or date) in D. This function should do for many tasks: http://dlang.org/phobos/std_process.html#shell string shell(string cmd); Runs cmd in a shell and returns its standard output. If the process could not be started or exits with an error code, throws an exception. Or maybe this one: http://dlang.org/phobos/std_stdio.html#popen (also search that page for the other popen, which calls the C function without the need for a File struct) Generally, anything you can do in C, you can also do in D by calling the C functions directly. |
November 16, 2012 Re: How to call external program in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | Thanks a lot, it was very helpful. |
November 17, 2012 Re: How to call external program in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sparsh Mittal | Le 16/11/2012 20:15, Sparsh Mittal a écrit : > I am new to D. > > Can you please tell, how to call external program in D. > > Example: in C, one can do this: > http://stackoverflow.com/questions/43116/how-can-i-run-an-external-program-from-c-and-parse-its-output > > > > I want to call an external program (e.g. ls or date) in D. > > > Thanks This is out of subject but for ls and date, you might want to get the informations directly in D. See - http://dlang.org/phobos/std_date.html - http://dlang.org/phobos/std_datetime.html - http://dlang.org/phobos/std_file.html#dirEntries |
Copyright © 1999-2021 by the D Language Foundation