1. Get the complete output of a program/command

Hello, I have been playing around with Euphoria recently :)

I want to get the (standard) output of a program or a command. I know that I can do this using `exec` and `read` but I am not sure how I can wait until the process ends... so really my question is "how to wait until a process ends" but I thought about the big picture and wanted to have a reference where I could go and look.

Can anyone help me out? Thanks in advance!

new topic     » topic index » view message » categorize

2. Re: Get the complete output of a program/command

Perhaps http://openeuphoria.org/docs/std_os.html#_1850_system_exec ?

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

3. Re: Get the complete output of a program/command

One other way is to use named pipes. Eu3 Standard Lirary and Eu4 Standard Library on RDS site contain a function named exec_command that shows how to do this.

Jean-Marc

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

4. Re: Get the complete output of a program/command

@irv I am not sure how system_exec would be helpful, it only returns the exit code...

@jmduro Thanks for the recommendation, I have seen quite a few of your contributions at the RDS archive, I will check your library/package out :)

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

5. Re: Get the complete output of a program/command

TheDcoder said...

... but I am not sure how I can wait until the process ends... so really my question is "how to wait until a process ends" ...

system_exec() returns an error code - therefore it must wait until the process it calls ends.

And, since the process is finished, you can just dump the output to a file, and use it:

include std/io.e 
include std/console.e 
system_exec("ls -la > lsoutput") 
object results = read_file("lsoutput",TEXT_MODE) 
display(results) 
new topic     » goto parent     » topic index » view message » categorize

6. Re: Get the complete output of a program/command

@irv I have thought about doing that but I do not want to... for a few reasons: 1. It invokes the shell, adds overhead. 2. Writes the output to disk, which can add a lot of overhead if the data to read is huge 3. The script will have to read all the data back, bad for hard disk

@jmduro I downloaded Eu3 Standard Library and found the exec_command function, but I quickly realized that I need to use the Eu4 Library as I was using Euphoria 4.x, but I did not find the exec_command function there... am I supposed to use the Eu3 Standard Library with Euphoria 4.x?

Thanks for the input guys :)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu