Re: question catching system message

new topic     » goto parent     » topic index » view thread      » older message » newer message

CChris wrote:
> 
> 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
> }}}
<eucode>?system_exec("command.com /c dir *.txt",2)</eucode>
{{{

> 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

CChirs,

Why couldn't you write a little program.

system("dir *.txt",2)

 ,bind it and call it myprog1.exe.

Then run }}}
<eucode> il=system_exec("myprog1.exe",2)</eucode>
{{{


Salix, 

This indeed would return an integer.

If you want a text report how about,

<eucode?

fn=open("myreport.txt")

d=dir(mydir)

for x= 1 to length(d) do
  puts(fn,d[x])
end for

close(fn)

</eucode>
{{{


I don't know exactly what info you want to obtain.

Just an idea.

This is untested.

Don Cole

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu