1. question catching system message
Is there a way to catch the reply of system() under Win32?
The following is incorrect sytax but that's what I mean:
sequence sx
sx=system("dir *.txt",2)
Currently the only way I can do it is this
sequence sx
system("dir *.txt > temp.txt",2)
sx=read_file("temp.txt")
Any tips?
Thanks,
Salix
2. Re: question catching system message
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
3. Re: question catching system message
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
4. Re: question catching system message
> > Hello Salix,
> >
> > Try system_exec(). Read the docs on it.
> >
>
> Not good without some work, said docs explicitly state this:
That's right. As well as I understand system_exec() returns
an integer. I want to catch the text that is returned by
the programme.
Regards,
Salix
5. Re: question catching system message
what's wrong this method its simple and effective.
You can also do
system("dir *.txt > temp.txt 2> error.txt",2)
then you have separated files for the command output and command error.
j.d.
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
6. Re: question catching system message
- Posted by don cole <doncole at pacbell.?e?>
Aug 11, 2007
-
Last edited Aug 12, 2007
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
7. Re: question catching system message
- Posted by Salix <salix at fre?mail?hu>
Aug 11, 2007
-
Last edited Aug 12, 2007
jacques deschênes wrote:
>
> what's wrong this method its simple and effective.
> You can also do
> system("dir *.txt > temp.txt 2> error.txt",2)
There's nothing wrong with it. It saves the output I want into a temp file.
But later I need to open that file, collect its content, and delete it
afterwards.
But to collect the output directly into an Euphoria object would be simplier
and even more effective.
(But I can live without it.)
Regards,
Salix
8. Re: question catching system message
- Posted by CChris <christian.cuvier at agri?ulture.gouv.f?>
Aug 11, 2007
-
Last edited Aug 12, 2007
Salix wrote:
>
> jacques deschênes wrote:
> >
> > what's wrong this method its simple and effective.
> > You can also do
> > system("dir *.txt > temp.txt 2> error.txt",2)
>
> There's nothing wrong with it. It saves the output I want into a temp file.
> But later I need to open that file, collect its content, and delete it
> afterwards.
>
> But to collect the output directly into an Euphoria object would be simplier
> and even more effective.
>
> (But I can live without it.)
>
> Regards,
>
> Salix
The text of the dir output is not returned, it is... simply written to a device,
possibly redirected.
If you use a RAM disk, then perhaps you can make DOS write to some area of
memory which it would think to be a file, and you'd peek that area. That's all I
can see.
Or - let's be fancy - make a TSR that trap DOS output to console, and have the
TSR communicate with your program using some interrupt.
CChris
9. Re: question catching system message
> Why couldn't you write a little program.
That's what I did. And that's what I wanted to avoid if possible.
But as I see there's no other way.
Rgds,
Salix