How to read output of exe files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

How to read output of exe files

Francesco Raymondi
Hi all,
I need to start external windows console program (exe) that returns one or more strings delimited by new line.
How can I read the output?

I use Visual Age 6.0.1

Regards,

Francesco Raymondi

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

Re: How to read output of exe files

Marten Feldtmann-2
Redirect the output of the console program (while starting it from VA) to a temporary file and read the temporary file after the console program terminated.

Marten

Am Montag, 7. Juli 2014 17:40:15 UTC+2 schrieb Francesco Raymondi:
Hi all,
I need to start external windows console program (exe) that returns one or more strings delimited by new line.
How can I read the output?

I use Visual Age 6.0.1

Regards,

Francesco Raymondi

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

How to read output of exe files

jtuchel
In reply to this post by Francesco Raymondi
Francesco,

I guess the program does write Strings to stdout. Afaik, executables only return integers.
So the best thing you can do ix what Marten suggests: start the program in a way so that its stdout output is redirected to a file. In unix, you start it with an additional parameter/option like this: myprogram > output.log. Not sure about Windows...

Joachim

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

Re: How to read output of exe files

Richard Sargent
Administrator
In reply to this post by Francesco Raymondi
On Monday, July 7, 2014 8:40:15 AM UTC-7, Francesco Raymondi wrote:
I need to start external windows console program (exe) that returns one or more strings delimited by new line.
How can I read the output?

There is AbtProgramStarter (I think that is the name) for running programs in a "fire and forget" mode. Look at how it is implemented to see how to run a specific command line or batch file.

There are also low-level Windows APIs for running an external program and being able to track its status. This API is much like the Unix-style API while being Windows (different). I haven't used it in more than a decade, so I don't recall the details. Look at AbtProgramStarter>>#startProgram, and then study the Windows documentation for the API to find out the details of what you can do with it.


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

Re: How to read output of exe files

Marten Feldtmann-2
I've published an application named MSKPlatformExtension and there is a class MSKProgramStarter - should give you a good idea how to start and wait for a program (under Windws).

Marten

Am Montag, 7. Juli 2014 19:13:08 UTC+2 schrieb Richard Sargent:
On Monday, July 7, 2014 8:40:15 AM UTC-7, Francesco Raymondi wrote:
I need to start external windows console program (exe) that returns one or more strings delimited by new line.
How can I read the output?

There is AbtProgramStarter (I think that is the name) for running programs in a "fire and forget" mode. Look at how it is implemented to see how to run a specific command line or batch file.

There are also low-level Windows APIs for running an external program and being able to track its status. This API is much like the Unix-style API while being Windows (different). I haven't used it in more than a decade, so I don't recall the details. Look at AbtProgramStarter>>#startProgram, and then study the Windows documentation for the API to find out the details of what you can do with it.


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

Re: How to read output of exe files

jtuchel
In reply to this post by Francesco Raymondi
I'd like to revive this old thread, because I am now in exactly the same boat: I'd like to call an external program and receive what it prints to stdout.
I've been playing a little with teh AbtProgramStarter and I can't see a way to use its stdout output, neither on Windows nor on Linux.

This temp file stuff does work, but it also requires some extra error handling, taking care of unique filenames and more stuff...

Joachim

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

Re: How to read output of exe files

Noschvie
Hi Joachim
for example, we are starting winSCP.exe from VAST using the AbtProgramStarter and redirecting the output to VAST by ReadFile...

\C equivalent: BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped).

please have a look to the screenshot. Is this what your are looking for?

Norbert

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

Re: How to read output of exe files

jtuchel
HI Norbert,

if I understand correctly, you are still using a file for stdout output of winSCP.

In our scenario, we get a "file" uploaded via http, which will stored in a CouchDB database using a simple http request. So initially there is no need to write the data to a file.

No we need to use an external program to process the data and give us the results.

So compared to the initial scenario, we'd have this flow:
  1. get the data in an http request
  2. save to a file on disk
  3. call the external program and hand it the filename
  4. the external program saves its results to disk
  5. we need to read this file in
  6. we store the contents of the file in the CouchDb using an http request
So we and the external program now read 2 files and store 2 files for each and every request. I am a bit worried this will be a lot of overhead, assuming we're receiving a few thousand of these requests a day. And we're hoping for growth, of course...

Since the external program could also return its result via stdout, we could save 1 file read and 1 file write operation per request. Sounds like low hanging fruit to me.

Joachim



Am Donnerstag, 4. April 2019 15:27:24 UTC+2 schrieb Norbert Schlemmer:
Hi Joachim
for example, we are starting winSCP.exe from VAST using the AbtProgramStarter and redirecting the output to VAST by ReadFile...

\C equivalent: BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped).

please have a look to the screenshot. Is this what your are looking for?

Norbert

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

Re: How to read output of exe files

Noschvie
Hi Joachim
no file will be written, the output will be redirected to VAST. Are you using Windows or Linux ?
Norbert

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

Re: How to read output of exe files

jtuchel
both, just to make things more interesting ;-)

Am Freitag, 5. April 2019 09:02:25 UTC+2 schrieb Norbert Schlemmer:
Hi Joachim
no file will be written, the output will be redirected to VAST. Are you using Windows or Linux ?
Norbert

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