1. system_exec()

Hi all,

I recently noticed, that on my system (Win 98/1st ed., Eu 2.4), after
calling 'system_exec("foo.exe", i)' my interpreted Eu program doesn't
continue with the next statement, but waits, until execution of 'foo.exe'
is finished. For instance try:
   if system_exec("calc", 2) then end if
   puts(1, "Hi there.")
   if getc(0) then end if

This behaviour is very useful in certain situations. Unfortunately, I
noticed it, when I had almost finished writing my own routine with this
functionality. getlost
At least on Win 98/1st ed., system() behaves differently. It does *not*
wait for the termination of the called program.

Is the behaviour of system()/system_exec() the same on all windows
platforms? How about Linux/FreeBSD? I think this should be clearly
documented.

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » topic index » view message » categorize

2. Re: system_exec()

Hi Al, thanks for your reply.

> Juergen Luethje wrote:
>>
>> Hi all,
>>
>> I recently noticed, that on my system (Win 98/1st ed., Eu 2.4), after
>> calling 'system_exec("foo.exe", i)' my interpreted Eu program doesn't
>> continue with the next statement, but waits, until execution of
>> 'foo.exe'
>> is finished. For instance try:
>>    if system_exec("calc", 2) then end if
>>    puts(1, "Hi there.")
>>    if getc(0) then end if
>>
>> This behaviour is very useful in certain situations. Unfortunately, I
>> noticed it, when I had almost finished writing my own routine with this
>> functionality. getlost
>> At least on Win 98/1st ed., system() behaves differently. It does *not*
>> wait for the termination of the called program.
>>
>> Is the behaviour of system()/system_exec() the same on all windows
>> platforms? How about Linux/FreeBSD? I think this should be clearly
>> documented.
>>
>
> Hi Juergen,
>
> I myself only use those functions when there is absolutely no
> other way of doing something smile

Me too. smile
However, since I came across this issue, I'd like to know, whether or
not system() always calls another program asynchronously, and
system_exc() always does this synchronously. Just because I'd like to
know as much as possible about "my" programming language. smile

> Can you use the win api?

Yes. As I mentioned, I have almost finished writing a routine, that
seems to be something like a self-written system_exec() function.
It uses the Win Api functions CreateProcess() and WaitForSingleObject().
But if system_exec() has the same functionality, why use a self-written
function instead?

I am writing a "wrapper" for the Eu2C Translator, so that there is the
additional command-line option '-res <resource file>' available.
This is simple and straightforward. The program just checks the
command-line options, and if '-res <resource file>' is given, this will
be extracted from the command line.
Then the statement
   x = system_exec("ecw.exe " & CommandLine, 2)
is executed.

If '-res <resource file>' was not given on the command-line, this was
just an awkward way of calling the translator. smile

If it was given, my program inserts additional lines into the files
"emake.bat" and "main_.c". Of course, these files are produced by the
translater, and I think my program shouldn't try to change them, before
the translater has finised it's work.

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » goto parent     » topic index » view message » categorize

3. Re: system_exec()

Hi Juergen,

> Hi all,
> 
> I recently noticed, that on my system (Win 98/1st ed., Eu 2.4), after
> calling 'system_exec("foo.exe", i)' my interpreted Eu program doesn't
> continue with the next statement, but waits, until execution of 'foo.exe'
> is finished. For instance try:
>    if system_exec("calc", 2) then end if
>    puts(1, "Hi there.")
>    if getc(0) then end if

system_exec() is function, so it waits the exit code 
to return it into your program from the child process.

> This behaviour is very useful in certain situations. Unfortunately, I
> noticed it, when I had almost finished writing my own routine with this
> functionality. getlost
> At least on Win 98/1st ed., system() behaves differently. It does *not*
> wait for the termination of the called program.

system() is procedure, so it doesn't wait any exit code,
but the plane DOS is not multitasking OS and DOS just
executes the commands step by step. 
OS waits.

> Is the behaviour of system()/system_exec() the same on all windows
> platforms? How about Linux/FreeBSD? I think this should be clearly
> documented.

Windows, Linux, FreeBSD are all multitasking OSs,  
so system() doesn't stop your parent program.

Just some thoughts, I am not too sure.

> Best regards,
>    Juergen

Best regards,
Igor Kachan
kinz at peterlink.ru

new topic     » goto parent     » topic index » view message » categorize

4. Re: system_exec()

On Fri, 11 Jul 2003 16:03:27 +0200, Juergen Luethje <j.lue at gmx.de>
wrote:

>However, since I came across this issue, I'd like to know, whether or
>not system() always calls another program asynchronously, and
>system_exc() always does this synchronously. Just because I'd like to
>know as much as possible about "my" programming language. smile
>
>> Can you use the win api?
>
>Yes. As I mentioned, I have almost finished writing a routine, that
>seems to be something like a self-written system_exec() function.
>It uses the Win Api functions CreateProcess() and WaitForSingleObject().
>But if system_exec() has the same functionality, why use a self-written
>function instead?

I've just remembered, I nicked "w32Func(jJumpto" from rundemos.exw
(the one that comes with win32lib) for use in MEditor, I think it got
rid of an annoying dos window briefly appearing when using system().

AFAIK, system_exec() always waits for the command to complete before
returning the exit code from the program.

Pete

new topic     » goto parent     » topic index » view message » categorize

5. Re: system_exec()

Hi Igor, thanks for your reply.

<snip>

> system_exec() is function, so it waits the exit code
> to return it into your program from the child process.

Uuuh... *Putting my hands up to my face* smile
Of course. If system_exec() wouldn't wait, then it's return value would
be undefined.

<snip>

> Windows, Linux, FreeBSD are all multitasking OSs,
> so system() doesn't stop your parent program.
>
> Just some thoughts, I am not too sure.

This also seems to be quite logical for me now. In contrast to
system_exec(),
"system() will start a new DOS or Linux/FreeBSD shell." [Eu 2.4 docs]
And AFAIK several shells don't wait for each other.

> Best regards,
> Igor Kachan
> kinz at peterlink.ru

Thank you,
   says Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » goto parent     » topic index » view message » categorize

6. Re: system_exec()

Hi Pete, thanks for your reply.

> On Fri, 11 Jul 2003 16:03:27 +0200, Juergen Luethje <j.lue at gmx.de>
> wrote:
>
>> However, since I came across this issue, I'd like to know, whether or
>> not system() always calls another program asynchronously, and
>> system_exc() always does this synchronously. Just because I'd like to
>> know as much as possible about "my" programming language. smile
>>
>>> Can you use the win api?
>>
>> Yes. As I mentioned, I have almost finished writing a routine, that
>> seems to be something like a self-written system_exec() function.
>> It uses the Win Api functions CreateProcess() and WaitForSingleObject().
>> But if system_exec() has the same functionality, why use a self-written
>> function instead?
>
> I've just remembered, I nicked "w32Func(jJumpto" from rundemos.exw
> (the one that comes with win32lib) for use in MEditor,

As far as I can see, that function calls the ShellExecute() API function
(provided by "shell32.dll").

> I think it got
> rid of an annoying dos window briefly appearing when using system().

Yes, I think on Windows, ShellExecute() is a good alternative to
system(). Thanks for the hint.

> AFAIK, system_exec() always waits for the command to complete before
> returning the exit code from the program.

Now, after having read the replies to my post, I think anything else
wouldn't make much sense.

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » goto parent     » topic index » view message » categorize

7. Re: system_exec()

Hello again Al, you wrote:

<snip>

> I had some problems with 'system' at one point.  If i remember
> right, it was only syncronous if you spec the number '2' as
> second parameter.

This is not what the docs say about the second argument of system().
And regarding a/synchronous execution, I didn't find any explicit
description in the docs at all.

> Havent tried the system_exec function yet,
> as i just recently upgraded from Euphoria 2.0 to 2.3 (and then 2.4)
> and 2.0 didnt have it smile

Interesting. I didn't know that, since 2.3 was the first Eu version
that I learned to know.

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » goto parent     » topic index » view message » categorize

8. Re: system_exec()

On Fri, Jul 11, 2003 at 07:15:38PM +0400, Igor Kachan wrote:
<snip> 
> > Is the behaviour of system()/system_exec() the same on all windows
> > platforms? How about Linux/FreeBSD? I think this should be clearly
> > documented.
> 
> Windows, Linux, FreeBSD are all multitasking OSs,  
> so system() doesn't stop your parent program.

Yes it does.

In linux/freebsd, EU system() is a wrapper for C's system(), as is
system_exec().

some pseudo code for thought:

void eu_system(eu_sequence command, eu_integer wait)
{
	system(make_char_array(command));
	... here would be the ncurses code that figures out what do do with wait
}

eu_integer eu_system_exec(eu_sequence command, eu_integer wait)
{
	int ret = system(make_char_array(command));
	... here would be the ncurses code that figures out what do do with wait
	return make_eu_integer(ret);
}

And, glibc/libc's system():

int system(char* command)
{
           int pid, status;

           if (command == 0)
               return 1;
           pid = fork();
           if (pid == -1)
               return -1;
           if (pid == 0) {
               char *argv[4];
               argv[0] = "sh";
               argv[1] = "-c";
               argv[2] = command;
               argv[3] = 0;
               execve("/bin/sh", argv, environ);
               exit(127);
           }
           do {
               if (waitpid(pid, &status, 0) == -1) {
                   if (errno != EINTR)
                       return -1;
               } else
                   return status;
           } while(1);
}

....in short, system() makes us wait in *nix too. (I did hook into glibc
so I could run a child process asychnronously ... but thats not something
provided by the language directly. At all.)

> 
> Just some thoughts, I am not too sure.
> 
> > Best regards,
> >    Juergen
> 
> Best regards,
> Igor Kachan
> kinz at peterlink.ru
> 
> 
> 
> TOPICA - Start your own email discussion group. FREE!
> 
> 

jbrown

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   | http://verify.stanford.edu/evote.html

new topic     » goto parent     » topic index » view message » categorize

9. Re: system_exec()

Hi Jim, thanks for your reply.

> On Fri, Jul 11, 2003 at 07:15:38PM +0400, Igor Kachan wrote:
> <snip>
>>> Is the behaviour of system()/system_exec() the same on all windows
>>> platforms? How about Linux/FreeBSD? I think this should be clearly
>>> documented.
>>
>> Windows, Linux, FreeBSD are all multitasking OSs,
>> so system() doesn't stop your parent program.
>
> Yes it does.
>
> In linux/freebsd, EU system() is a wrapper for C's system(), as is
> system_exec().
>
> some pseudo code for thought:
>
> void eu_system(eu_sequence command, eu_integer wait)
> {
> 	system(make_char_array(command));
> 	... here would be the ncurses code that figures out what do do with wait
> }
>
> eu_integer eu_system_exec(eu_sequence command, eu_integer wait)
> {
> 	int ret = system(make_char_array(command));
> 	... here would be the ncurses code that figures out what do do with wait
> 	return make_eu_integer(ret);
> }
>
> And, glibc/libc's system():
>
> int system(char* command)
> {
>            int pid, status;
>
>            if (command == 0)
>                return 1;
>            pid = fork();
>            if (pid == -1)
>                return -1;
>            if (pid == 0) {
>                char *argv[4];
>                argv[0] = "sh";
>                argv[1] = "-c";
>                argv[2] = command;
>                argv[3] = 0;
>                execve("/bin/sh", argv, environ);
>                exit(127);
>            }
>            do {
>                if (waitpid(pid, &status, 0) == -1) {
>                    if (errno != EINTR)
>                        return -1;
>                } else
>                    return status;
>            } while(1);
> }
>
> ....in short, system() makes us wait in *nix too. (I did hook into glibc
> so I could run a child process asychnronously ... but thats not something
> provided by the language directly. At all.)

<snip>


I'll try to summarize (S: run a child process  sychnronously,
                       A: run a child process asychnronously):


         |    Euphoria command
         |
         | system() | system_exec()
---------+----------+--------------
DOS      |    S     |      S
---------+----------+--------------
Windows  |    A     |      S
---------+----------+--------------
Linux    |    S     |      S
---------+----------+--------------
FreeBSD  |    S     |      S



Is this the bottom line?

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » goto parent     » topic index » view message » categorize

10. Re: system_exec()

On Fri, Jul 11, 2003 at 11:49:25PM +0200, Juergen Luethje wrote:
> 
> 
> Hi Jim, thanks for your reply.
> 
> > On Fri, Jul 11, 2003 at 07:15:38PM +0400, Igor Kachan wrote:
> > <snip>
> >>> Is the behaviour of system()/system_exec() the same on all windows
> >>> platforms? How about Linux/FreeBSD? I think this should be clearly
> >>> documented.
> >>
> >> Windows, Linux, FreeBSD are all multitasking OSs,
> >> so system() doesn't stop your parent program.
> >
> > Yes it does.
> >
> > In linux/freebsd, EU system() is a wrapper for C's system(), as is
> > system_exec().
> >
> > some pseudo code for thought:
> >
> > void eu_system(eu_sequence command, eu_integer wait)
> > {
> > 	system(make_char_array(command));
> > 	... here would be the ncurses code that figures out what do do with wait
> > }
> >
> > eu_integer eu_system_exec(eu_sequence command, eu_integer wait)
> > {
> > 	int ret = system(make_char_array(command));
> > 	... here would be the ncurses code that figures out what do do with wait
> > 	return make_eu_integer(ret);
> > }
> >
> > And, glibc/libc's system():
> >
> > int system(char* command)
> > {
> >            int pid, status;
> >
> >            if (command == 0)
> >                return 1;
> >            pid = fork();
> >            if (pid == -1)
> >                return -1;
> >            if (pid == 0) {
> >                char *argv[4];
> >                argv[0] = "sh";
> >                argv[1] = "-c";
> >                argv[2] = command;
> >                argv[3] = 0;
> >                execve("/bin/sh", argv, environ);
> >                exit(127);
> >            }
> >            do {
> >                if (waitpid(pid, &status, 0) == -1) {
> >                    if (errno != EINTR)
> >                        return -1;
> >                } else
> >                    return status;
> >            } while(1);
> > }
> >
> > ....in short, system() makes us wait in *nix too. (I did hook into glibc
> > so I could run a child process asychnronously ... but thats not something
> > provided by the language directly. At all.)
> 
> <snip>
> 
> 
> I'll try to summarize (S: run a child process  sychnronously,
>                        A: run a child process asychnronously):
> 
> 
>          |    Euphoria command
>          |
>          | system() | system_exec()
> ---------+----------+--------------
> DOS      |    S     |      S
> ---------+----------+--------------
> Windows  |    A     |      S
> ---------+----------+--------------
> Linux    |    S     |      S
> ---------+----------+--------------
> FreeBSD  |    S     |      S
> 
> 
> Is this the bottom line?

I thought that system() under Windows would be 'S' not 'A' ... but then again
I probably wouldn't know...

jbrown

> 
> Best regards,
>    Juergen
> 
> -- 
>  /"\  ASCII ribbon campain  |    |\      _,,,---,,_
>  \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
>   X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
>  / \  and unneeded MIME     |  '---''(_/--'  `-'\_)
> 
> 
> 
> TOPICA - Start your own email discussion group. FREE!
> 
> 

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   | http://verify.stanford.edu/evote.html

new topic     » goto parent     » topic index » view message » categorize

11. Re: system_exec()

Hi Jim, you wrote:

> On Fri, Jul 11, 2003 at 11:49:25PM +0200, Juergen Luethje wrote:

<big snip>

>> I'll try to summarize (S: run a child process  sychnronously,
>>                        A: run a child process asychnronously):
Should be "a/synchronously", of course.   -------^^^^^^^^^^^^^^

>>
>>          |    Euphoria command
>>          |
>>          | system() | system_exec()
>> ---------+----------+--------------
>> DOS      |    S     |      S
>> ---------+----------+--------------
>> Windows  |    A     |      S
>> ---------+----------+--------------
>> Linux    |    S     |      S
>> ---------+----------+--------------
>> FreeBSD  |    S     |      S
>>
>>
>> Is this the bottom line?
>
> I thought that system() under Windows would be 'S' not 'A' ... but
> then again I probably wouldn't know...

I only can say that under Windows 98, 'A' is correct for system().
I don't think it's likely, that other Windows versions behave different
regarding this point.
Interestingly -- provided this litte table is correct --, the 'A' for
Windows is the exception. The table is almost contrary to what I had
expected. smile

Anyway, the question of practical importance for me at the moment was
the behaviour of system_exec() under Windows, and that seems pretty
clear now.
Thanks again to all, who helped me.

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » goto parent     » topic index » view message » categorize

12. Re: system_exec()

Hello again Al, you wrote:

> Juergen Luethje wrote:
>>
>>
>> Hi Jim, you wrote:
>>
>>> On Fri, Jul 11, 2003 at 11:49:25PM +0200, Juergen Luethje wrote:
>>
>> <big snip>
>>
>>>> I'll try to summarize (S: run a child process  sychnronously,
>>>>                        A: run a child process asychnronously):
>> Should be "a/synchronously", of course.   -------^^^^^^^^^^^^^^
>>
>>>>
>>>>          |    Euphoria command
>>>>          |
>>>>          | system() | system_exec()
>>>> ---------+----------+--------------
>>>> DOS      |    S     |      S
>>>> ---------+----------+--------------
>>>> Windows  |    A     |      S
>>>> ---------+----------+--------------
>>>> Linux    |    S     |      S
>>>> ---------+----------+--------------
>>>> FreeBSD  |    S     |      S
>>>>
>>>>
>>>> Is this the bottom line?
>>>
>>> I thought that system() under Windows would be 'S' not 'A' ... but
>>> then again I probably wouldn't know...
>>
>> I only can say that under Windows 98, 'A' is correct for system().
>> I don't think it's likely, that other Windows versions behave different
>> regarding this point.
>> Interestingly -- provided this litte table is correct --, the 'A' for
>> Windows is the exception. The table is almost contrary to what I had
>> expected. smile
>>
>> Anyway, the question of practical importance for me at the moment was
>> the behaviour of system_exec() under Windows, and that seems pretty
>> clear now.
>> Thanks again to all, who helped me.
>>
>> Best regards,
>>    Juergen
>
>
> Hello again,
>
> It looks to me that System() is synchronous.  If it werent
> my EuViewer wouldnt work correctly.

Hmm... I'd like to have a look at it, but I didn't find anything, when
I searched for "EuViewer" in the RDS archieve.

> When i said it only worked with a '2' as second argument,
> it was actually a much older version of Euphoria.
> Apparently, either a 0 or a 2 works ok with the viewer (v2.4 tested).
> This means it's synchronous.  I didnt try '1' because i dont want
> a beep smile

OK, then we'll only use 0 or 2 as second parameter for system(). smile

Please try the following code on Windows:
   system("calc", 2)
   puts(1, "Hi there.")
   if getc(0) then end if

At least on Windows 98, the console window saying "Hi there!" pops up,
although the calculator is still running.
That's why I thought, that on Windows system() is asynchronous.

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » goto parent     » topic index » view message » categorize

13. Re: system_exec()

On Sun, Jul 13, 2003 at 06:07:17PM +0200, Juergen Luethje wrote:
> 
> 
> Hello again Al, you wrote:
> 
> > Juergen Luethje wrote:
> >>
> >>
> >> Hi Jim, you wrote:
> >>
> >>> On Fri, Jul 11, 2003 at 11:49:25PM +0200, Juergen Luethje wrote:
> >>
> >> <big snip>
> >>
> >>>> I'll try to summarize (S: run a child process  sychnronously,
> >>>>                        A: run a child process asychnronously):
> >> Should be "a/synchronously", of course.   -------^^^^^^^^^^^^^^
> >>
> >>>>
> >>>>          |    Euphoria command
> >>>>          |
> >>>>          | system() | system_exec()
> >>>> ---------+----------+--------------
> >>>> DOS      |    S     |      S
> >>>> ---------+----------+--------------
> >>>> Windows  |    A     |      S
> >>>> ---------+----------+--------------
> >>>> Linux    |    S     |      S
> >>>> ---------+----------+--------------
> >>>> FreeBSD  |    S     |      S
> >>>>
> >>>>
> >>>> Is this the bottom line?
> >>>
> >>> I thought that system() under Windows would be 'S' not 'A' ... but
> >>> then again I probably wouldn't know...
> >>
> >> I only can say that under Windows 98, 'A' is correct for system().
> >> I don't think it's likely, that other Windows versions behave different
> >> regarding this point.
> >> Interestingly -- provided this litte table is correct --, the 'A' for
> >> Windows is the exception. The table is almost contrary to what I had
> >> expected. smile
> >>
> >> Anyway, the question of practical importance for me at the moment was
> >> the behaviour of system_exec() under Windows, and that seems pretty
> >> clear now.
> >> Thanks again to all, who helped me.
> >>
> >> Best regards,
> >>    Juergen
> >
> >
> > Hello again,
> >
> > It looks to me that System() is synchronous.  If it werent
> > my EuViewer wouldnt work correctly.
> 
> Hmm... I'd like to have a look at it, but I didn't find anything, when
> I searched for "EuViewer" in the RDS archieve.

> 
> > When i said it only worked with a '2' as second argument,
> > it was actually a much older version of Euphoria.
> > Apparently, either a 0 or a 2 works ok with the viewer (v2.4 tested).
> > This means it's synchronous.  I didnt try '1' because i dont want
> > a beep smile
> 
> OK, then we'll only use 0 or 2 as second parameter for system(). smile

0, 1, and 2 all have the same effect ... they are all synchronous.

> 
> Please try the following code on Windows:
>    system("calc", 2)
>    puts(1, "Hi there.")
>    if getc(0) then end if
> 
> At least on Windows 98, the console window saying "Hi there!" pops up,
> although the calculator is still running.
> That's why I thought, that on Windows system() is asynchronous.

Thats a special property of Windows GUI programs. Not sure why M$
choose to do it like that tho.

Doing system("kcalc &", 2) on a linux/freebsd system via exu would have
system act async as well (since the '&' tells it to run in the background
instead of the foreground).

jbrown

> 
> Best regards,
>    Juergen
> 
> -- 
>  /"\  ASCII ribbon campain  |    |\      _,,,---,,_
>  \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
>   X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
>  / \  and unneeded MIME     |  '---''(_/--'  `-'\_)
> 
> 
> 
> TOPICA - Start your own email discussion group. FREE!
> 
> 

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   | http://verify.stanford.edu/evote.html

new topic     » goto parent     » topic index » view message » categorize

14. Re: system_exec()

----- Original Message -----
From: "Pete Lomax" <petelomax at blueyonder.co.uk>



>
>
> On Fri, 11 Jul 2003 16:03:27 +0200, Juergen Luethje <j.lue at gmx.de>
> wrote:
>
> >However, since I came across this issue, I'd like to know, whether or
> >not system() always calls another program asynchronously, and
> >system_exc() always does this synchronously. Just because I'd like to
> >know as much as possible about "my" programming language. smile
> >
> >> Can you use the win api?
> >
> >Yes. As I mentioned, I have almost finished writing a routine, that
> >seems to be something like a self-written system_exec() function.
> >It uses the Win Api functions CreateProcess() and WaitForSingleObject().
> >But if system_exec() has the same functionality, why use a self-written
> >function instead?
>
> I've just remembered, I nicked "w32Func(jJumpto" from rundemos.exw
> (the one that comes with win32lib) for use in MEditor, I think it got
> rid of an annoying dos window briefly appearing when using system().

And in rundemos.exw, I nicked that "jJumpto =
define_c_func(lib,"ShellExecuteA"...", (and the "Jump_to" procedure that
uses it), from Wolfgang Fritz, who in turn got it from someone known as
"DaJaRo".  :)

Dan Moyer

>
> AFAIK, system_exec() always waits for the command to complete before
> returning the exit code from the program.
>
> Pete
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>

new topic     » goto parent     » topic index » view message » categorize

15. Re: system_exec()

On Mon, 14 Jul 2003 23:27:59 -0700 (07/15/03 16:27:59)
, Dan Moyer <DANIELMOYER at prodigy.net> wrote:

[snip]
>> I've just remembered, I nicked "w32Func(jJumpto" from rundemos.exw
>> (the one that comes with win32lib) for use in MEditor, I think it got
>> rid of an annoying dos window briefly appearing when using system().
>
> And in rundemos.exw, I nicked that "jJumpto =
> define_c_func(lib,"ShellExecuteA"...", (and the "Jump_to" procedure that
> uses it), from Wolfgang Fritz, who in turn got it from someone known as
> "DaJaRo".  :)
>

Which is the same as the shellExecuteEx() routine already in win32lib, BTW.

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

16. Re: system_exec()

----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: system_exec()


>
>
> On Mon, 14 Jul 2003 23:27:59 -0700 (07/15/03 16:27:59)
> , Dan Moyer <DANIELMOYER at prodigy.net> wrote:
>
> [snip]
> >> I've just remembered, I nicked "w32Func(jJumpto" from rundemos.exw
> >> (the one that comes with win32lib) for use in MEditor, I think it got
> >> rid of an annoying dos window briefly appearing when using system().
> >
> > And in rundemos.exw, I nicked that "jJumpto =
> > define_c_func(lib,"ShellExecuteA"...", (and the "Jump_to" procedure that
> > uses it), from Wolfgang Fritz, who in turn got it from someone known as
> > "DaJaRo".  :)
> >
>
> Which is the same as the shellExecuteEx() routine already in win32lib,
BTW.
>

oh...but I *think* it wasn't there when I first began RunDemos?

Dan Moyer

> --
>
> cheers,
> Derek Parnell
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>

new topic     » goto parent     » topic index » view message » categorize

17. Re: system_exec()

On Mon, 14 Jul 2003 23:59:26 -0700 (07/15/03 16:59:26)
, Dan Moyer <DANIELMOYER at prodigy.net> wrote:

>
>
> ----- Original Message -----
> From: "Derek Parnell" <ddparnell at bigpond.com>
> To: "EUforum" <EUforum at topica.com>
> Subject: Re: system_exec()
>
>
>> On Mon, 14 Jul 2003 23:27:59 -0700 (07/15/03 16:27:59)
>> , Dan Moyer <DANIELMOYER at prodigy.net> wrote:
>>
>> [snip]
>> >> I've just remembered, I nicked "w32Func(jJumpto" from rundemos.exw
>> >> (the one that comes with win32lib) for use in MEditor, I think it got
>> >> rid of an annoying dos window briefly appearing when using system().
>> >
>> > And in rundemos.exw, I nicked that "jJumpto =
>> > define_c_func(lib,"ShellExecuteA"...", (and the "Jump_to" procedure 
>> that
>> > uses it), from Wolfgang Fritz, who in turn got it from someone known 
>> as
>> > "DaJaRo".  :)
>> >
>>
>> Which is the same as the shellExecuteEx() routine already in win32lib,
> BTW.
>>
>
> oh...but I *think* it wasn't there when I first began RunDemos?
>

You're correct, but i wanted people to know that they don't have to borrow 
from RunDemos anymore, unless they want to.

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

18. Re: system_exec()

----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: system_exec()


>
>
> On Mon, 14 Jul 2003 23:59:26 -0700 (07/15/03 16:59:26)
> , Dan Moyer <DANIELMOYER at prodigy.net> wrote:
>
> >
> > ----- Original Message -----
> > From: "Derek Parnell" <ddparnell at bigpond.com>
> > To: "EUforum" <EUforum at topica.com>
> > Sent: Monday, July 14, 2003 11:37 PM
> > Subject: Re: system_exec()
> >
> >
> >> On Mon, 14 Jul 2003 23:27:59 -0700 (07/15/03 16:27:59)
> >> , Dan Moyer <DANIELMOYER at prodigy.net> wrote:
> >>
> >> [snip]
> >> >> I've just remembered, I nicked "w32Func(jJumpto" from rundemos.exw
> >> >> (the one that comes with win32lib) for use in MEditor, I think it
got
> >> >> rid of an annoying dos window briefly appearing when using system().
> >> >
> >> > And in rundemos.exw, I nicked that "jJumpto =
> >> > define_c_func(lib,"ShellExecuteA"...", (and the "Jump_to" procedure
> >> that
> >> > uses it), from Wolfgang Fritz, who in turn got it from someone known
> >> as
> >> > "DaJaRo".  :)
> >> >
> >>
> >> Which is the same as the shellExecuteEx() routine already in win32lib,
> > BTW.
> >>
> >
> > oh...but I *think* it wasn't there when I first began RunDemos?
> >
>
> You're correct, but i wanted people to know that they don't have to borrow
> from RunDemos anymore, unless they want to.
>

Ok doky!  :)

Dan

> --
>
> cheers,
> Derek Parnell
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>

new topic     » goto parent     » topic index » view message » categorize

19. Re: system_exec()

Hi Al, you wrote:

> Juergen Luethje wrote:

<big snip>

>> Please try the following code on Windows:
>>    system("calc", 2)
>>    puts(1, "Hi there.")
>>    if getc(0) then end if
>>
>> At least on Windows 98, the console window saying "Hi there!" pops up,
>> although the calculator is still running.
>> That's why I thought, that on Windows system() is asynchronous.
>>
>
> Hi again Juergen,
>
> I see what you mean.  Windows programs like that seem to
> run async, probably because they dont return a value.
> I'll have to look more at this i guess, but the decompressor
> i was talking about runs and then returns, and then the
> program displays the bitmap from the file the decompressor
> creates.  If it didnt happen that way, the program would
> display the wrong bitmap or cause an error because the file
> wouldnt be there yet smile
> All i can say is that for this kind of .exe it runs synchronously.
>
> If you want to check it out, do a search for 'jpg' in the archive.
> It's not the 'JPG Reader', it's the 'Viewer for .JPG and .BMP'.
> The viewer calls the .exe program that decompresses the jpg.
> The 'JPG Reader' is a Euphoria jpg decompressor, and doesnt call
> any exe programs.
>
> Let me know what you find out...

I found your program, and looked at it, and I also see what you mean.
Unfortunately, ATM I have no explanation for this contradiction(?), too.

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

new topic     » goto parent     » topic index » view message » categorize

20. system_exec()

i found out that system() and system_exec() dont return until the called program
finishes. so

what can i use instead that will return immediately? non-win32 specific.

new topic     » goto parent     » topic index » view message » categorize

21. Re: system_exec()

> i found out that system() and system_exec() dont return until the called
> program finishes. so
> 
> what can i use instead that will return immediately? non-win32 specific.

http://www.ss64.com/

I found this site the other day, its a list of like *every* shell
command on Windows NT/XP, Linux BASH, OS X, and Oracle 8i. At least
the useful ones, very handy, especially on Windows.

You may be looking for this:
    http://www.ss64.com/bash/exec.html

as in:
    system( "exec command", 2 )

which should return immediately. :)

HTH,
~Greg

new topic     » goto parent     » topic index » view message » categorize

22. Re: system_exec()

Tone Škoda wrote:
> 
> i found out that system() and system_exec() dont return until the called
> program finishes.
> so 
> 
> what can i use instead that will return immediately? non-win32 specific.

Check this out:

http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=6&fromYear=1&toMonth=3&toYear=A&postedBy=&keywords=system+return+immediately

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

23. Re: system_exec()

Greg:
i don't know what would "command" in system( "exec command", 2 ) be?

cklester:
thanks for reminding me. so far i didn't find what ive been searching for, only
one example of doing it with open_dll() which cant be used in dos.


This example:

puts (1, "executing\n")
system("explorer.exe", 2)
system("calc.exe", 2)
system("notepad.exe", 2)
system("charmap.exe", 2)
puts (1, "done\n")

opens explorer.exe and calc.exe and then it halts. it looks like it depends on
program being executed: explorer.exe returns immediately, calc.exe not (i know
because i tried reverse order).

new topic     » goto parent     » topic index » view message » categorize

24. Re: system_exec()

> Greg:
> i don't know what would "command" in system( "exec command", 2 ) be?

Sorry.. "command" would be whatever app you want to launch.

~Greg

new topic     » goto parent     » topic index » view message » categorize

25. Re: system_exec()

Greg Haberek wrote:
> 
> > Greg:
> > i don't know what would "command" in system( "exec command", 2 ) be?
> 
> Sorry.. "command" would be whatever app you want to launch.
> 
> ~Greg
> 
> 


it doesnt work:
system("exec C:\\EUPHORIA\\BIN\\EX.EXE", 2)
it says:
"bad command or file name"

new topic     » goto parent     » topic index » view message » categorize

26. Re: system_exec()

>From: Tone =8Akoda <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Re: system_exec()
>Date: Tue, 29 Mar 2005 14:36:04 -0800
>
>posted by: Tone =8Akoda <tskoda at email.si>
>
>it doesnt work:
>system("exec C:\\EUPHORIA\\BIN\\EX.EXE", 2)
>it says:
>"bad command or file name"

Try system("start calc.exe", 2)

>

~[ WingZone ]~
http://wingzone.tripod.com/

new topic     » goto parent     » topic index » view message » categorize

27. Re: system_exec()

Tone *koda wrote:
> 
> Greg Haberek wrote:
> > 
> > > Greg:
> > > i don't know what would "command" in system( "exec command", 2 ) be?
> > 
> > Sorry.. "command" would be whatever app you want to launch.
> > 
> > ~Greg
> > 
> > 
> it doesnt work:
> system("exec C:\\EUPHORIA\\BIN\\EX.EXE", 2)
> it says:
> "bad command or file name"
> 

AFAIK that's a *nix command.

Regards, Alexander Toresson

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu