[eiffel-users] Running external applications from Eiffel

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[eiffel-users] Running external applications from Eiffel

Alexandr Naumchev
Hi,

Does anyone know how to run an external application from inside of an Eiffel program?

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
XEL
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [eiffel-users] Running external applications from Eiffel

XEL
On Thu, 13 Jul 2017 01:09:47 -0700 (PDT)
Alexandr Naumchev <[hidden email]> wrote:

> Hi,
>
> Does anyone know how to run an external application from inside of an
> Eiffel program?

The easiest way is with a wrapper:

-- #include <stdlib.h>
-- int system(const char *command);


        system (command: POINTER): INTEGER is

                external
                        "C | %"stdlib.h%""
                end

Then you pass a pointer to your null-terminated command string from Eiffel.

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[eiffel-users] Re: Running external applications from Eiffel

Finnian Reilly
In reply to this post by Alexandr Naumchev
Hi Alexandr,
the Eiffel-Loop project has a sophisticated  framework for wrapping OS commands and processing captured output and also error messages. See library OS-command.ecf. There are very many examples provided in the examples directory and also the tools directory. If you don't wish to take advantage of the full capabilities of the framework, two "quick and easy" classes are provided to give you basic command template substitution functionality.
  1. EL_OS_COMMAND
  2. EL_CAPTURED_OS_COMMAND
Library features
These are just a few of the features of the library
  • Makes it possible to create a cross platform interface to commands that are similar but fundamentally different across platforms. For example the Unix find command and the Windows dir command have a common interface in the classes EL_FIND_DIRECTORIES_COMMAND_I and EL_FIND_FILES_COMMAND_I despite the fact that they have different output encodings and different output conventions.
  • Makes it easy to capture and process both standard and error output. There is no need to add anything explicitly to the the command template to capture the output. It happens automatically during the template expansion if you inherit from EL_CAPTURED_OS_COMMAND_I. All you need to do is implement the do_with_lines procedure to process the output.
  • Any error output is automatically available in the errors attribute as a list of strings.
  • Makes use of the Evolicity template substitution library for creating command templates and substituting the value of class attributes or functions. The templates can be spread across multiple lines and contain conditional branches using constructs #if <condition> then #else #end
  • Automatic escaping of reserved characters in path subtitution variables on Unix platforms
  • Automatic quoting of path subtitution variables for the Windows platform

regards

Finnian

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [eiffel-users] Running external applications from Eiffel

Bertrand Meyer (ETH)
In reply to this post by XEL
Note that the keyword "is" disappeared from feature declarations sometime in the previous millennium. Just omit it.

-- Bertrand Meyer
LASER summer school: Software for Robotics (Registration deadline: 15 July)
Elba Island (Italy), 9-17 September 2017
http://laser-foundation.org 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of XEL
Sent: Thursday, July 13, 2017 13:08
To: [hidden email]
Subject: Re: [eiffel-users] Running external applications from Eiffel

On Thu, 13 Jul 2017 01:09:47 -0700 (PDT) Alexandr Naumchev <[hidden email]> wrote:

> Hi,
>
> Does anyone know how to run an external application from inside of an
> Eiffel program?

The easiest way is with a wrapper:

-- #include <stdlib.h>
-- int system(const char *command);


        system (command: POINTER): INTEGER is

                external
                        "C | %"stdlib.h%""
                end

Then you pass a pointer to your null-terminated command string from Eiffel.

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [eiffel-users] Running external applications from Eiffel

'Alexander Kogtenkov' via Eiffel Users
In reply to this post by Alexandr Naumchev
There is a library that is included with every EiffelStudio installation: Process. It works on all supported platforms and allows running an external application and redirecting standard input and output from/to files and user-defined agents. The only limitation is that it does not work with SCOOP.

A simplified version of the library, called BaseProcess, works also with SCOOP, but does not support redirection to agents yet.

You can easily find both when adding a new library to your project in EiffelStudio by specifying the filter "process".

An example on how to use the Process library can be found at https://www.eiffel.org/article/how_to_get_the_output_of_a_command_using_eiffelprocess

Hope this helps,
Alexander Kogtenkov

Alexandr Naumchev <[hidden email]>:

Hi,

Does anyone know how to run an external application from inside of an Eiffel program?


--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [eiffel-users] Running external applications from Eiffel

Finnian Reilly
I once tried to integrate the ISE process library with the Eiffel-loop OS-command library and experienced a serious latency issue. So I reverted back to using {EXECUTION_ENVIRONMENT}.system. I reported it as a bug back in 2011 with the synopsis: Running external commands using Unix implementation of PROCESS library is extremely slow

I checked the status of this report and it is still open, so I can only assume that it hasn't been fixed. In summary, a series of OS commands that should only take seconds to execute, can end up taking minutes.
-- Finnian

On Thursday, 13 July 2017 15:12:42 UTC+1, Alexander Kogtenkov wrote:
There is a library that is included with every EiffelStudio installation: Process. It works on all supported platforms and allows running an external application and redirecting standard input and output from/to files and user-defined agents. The only limitation is that it does not work with SCOOP.

A simplified version of the library, called BaseProcess, works also with SCOOP, but does not support redirection to agents yet.

You can easily find both when adding a new library to your project in EiffelStudio by specifying the filter "process".

An example on how to use the Process library can be found at <a href="https://www.eiffel.org/article/how_to_get_the_output_of_a_command_using_eiffelprocess" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.eiffel.org%2Farticle%2Fhow_to_get_the_output_of_a_command_using_eiffelprocess\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH_69OdXkMmSTcovO3kjKSv5K0V7w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.eiffel.org%2Farticle%2Fhow_to_get_the_output_of_a_command_using_eiffelprocess\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH_69OdXkMmSTcovO3kjKSv5K0V7w&#39;;return true;">https://www.eiffel.org/article/how_to_get_the_output_of_a_command_using_eiffelprocess

Hope this helps,
Alexander Kogtenkov

Alexandr Naumchev <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kT9wvlzhCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">anau...@...>:

Hi,

Does anyone know how to run an external application from inside of an Eiffel program?


--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re[2]: [eiffel-users] Running external applications from Eiffel

'Alexander Kogtenkov' via Eiffel Users
Quite a bit of work was put into improvement of the simplified version of Process library, BaseProcess, that can be used like "system", but with more flexibility, compatibility and efficiency in mind compared to the Process library. The library is available starting from the previous release, 17.01.

In particular BaseProcess runs 2 times faster than "system" on a Windows machine.

So, if you do not want to use asynchronous agent-based input-output for external processes, I would recommend using this library instead of the "system" call.

Alexander Kogtenkov


Finnian Reilly <[hidden email]>:

I once tried to integrate the ISE process library with the Eiffel-loop OS-command library and experienced a serious latency issue. So I reverted back to using {EXECUTION_ENVIRONMENT}.system. I reported it as a bug back in 2011 with the synopsis: Running external commands using Unix implementation of PROCESS library is extremely slow

I checked the status of this report and it is still open, so I can only assume that it hasn't been fixed. In summary, a series of OS commands that should only take seconds to execute, can end up taking minutes.
-- Finnian

On Thursday, 13 July 2017 15:12:42 UTC+1, Alexander Kogtenkov wrote:
There is a library that is included with every EiffelStudio installation: Process. It works on all supported platforms and allows running an external application and redirecting standard input and output from/to files and user-defined agents. The only limitation is that it does not work with SCOOP.

A simplified version of the library, called BaseProcess, works also with SCOOP, but does not support redirection to agents yet.

You can easily find both when adding a new library to your project in EiffelStudio by specifying the filter "process".

An example on how to use the Process library can be found at https://www.eiffel.org/article/how_to_get_the_output_of_a_command_using_eiffelprocess

Hope this helps,
Alexander Kogtenkov

Alexandr Naumchev <[hidden email]>:

Hi,

Does anyone know how to run an external application from inside of an Eiffel program?


--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [eiffel-users] Re: Running external applications from Eiffel

Thomas Beale-4
In reply to this post by Finnian Reilly

I'm sure Finnian's facility is more modern than mine, but if you want to look at some code that knows how to run a command on Linunx, Mac, Windows or cygwin, with parameters and callback and return status, there is some code here that uses the process framework. Or get the whole git repo.

I use this to call git commands, browsers and a few other things on various platforms.

- thomas

On 13/07/2017 08:11, Finnian Reilly wrote:
Hi Alexandr,
the Eiffel-Loop project has a sophisticated  framework for wrapping OS commands and processing captured output and also error messages. See library OS-command.ecf. There are very many examples provided in the examples directory and also the tools directory. If you don't wish to take advantage of the full capabilities of the framework, two "quick and easy" classes are provided to give you basic command template substitution functionality.
  1. EL_OS_COMMAND
  2. EL_CAPTURED_OS_COMMAND
Library features
These are just a few of the features of the library
  • Makes it possible to create a cross platform interface to commands that are similar but fundamentally different across platforms. For example the Unix find command and the Windows dir command have a common interface in the classes EL_FIND_DIRECTORIES_COMMAND_I and EL_FIND_FILES_COMMAND_I despite the fact that they have different output encodings and different output conventions.
  • Makes it easy to capture and process both standard and error output. There is no need to add anything explicitly to the the command template to capture the output. It happens automatically during the template expansion if you inherit from EL_CAPTURED_OS_COMMAND_I. All you need to do is implement the do_with_lines procedure to process the output.
  • Any error output is automatically available in the errors attribute as a list of strings.
  • Makes use of the Evolicity template substitution library for creating command templates and substituting the value of class attributes or functions. The templates can be spread across multiple lines and contain conditional branches using constructs #if <condition> then #else #end
  • Automatic escaping of reserved characters in path subtitution variables on Unix platforms
  • Automatic quoting of path subtitution variables for the Windows platform

regards

Finnian

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.


--
Thomas Beale
Principal, Ars Semantica
Consultant, ABD Team, Intermountain Healthcare
Management Board, Specifications Program Lead, openEHR Foundation
Chartered IT Professional Fellow, BCS, British Computer Society
Health IT blog | Culture blog

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Loading...