Re: question catching system message
- Posted by CChris <christian.cuvier at ?gricultur?.gouv.fr> Aug 11, 2007
- 479 views
don cole wrote: > > Salix wrote: > > > > Is there a way to catch the reply of system() under Win32? > > The following is incorrect sytax but that's what I mean: > > }}} <eucode> > > sequence sx > > sx=system("dir *.txt",2) > > </eucode> {{{ > > > > Currently the only way I can do it is this > > }}} <eucode> > > sequence sx > > system("dir *.txt > temp.txt",2) > > sx=read_file("temp.txt") > > </eucode> {{{ > > > > Any tips? > > > > Thanks, > > > > Salix > > Hello Salix, > > Try system_exec(). Read the docs on it. > > Don Cole Not good without some work, said docs explicitly state this: On DOS32 or WIN32, system_exec() will only run .exe and .com programs. To run .bat files, or built-in DOS commands, you need system(). Some commands, such as DEL, are not programs, they are actually built-in to the command interpreter. If you have an external command called dir.com, system_exec() will work for you. What you can do for internal commands is this
?system_exec("command.com /c dir *.txt",2)
command.com is an external program, and the /C switch instructs it to execute the remainder of string and return status code. command.com will be done in a secondary DOS shell. Under Windows, use cmd.exe rather than command.com if it is available. HTH CChris