
-----------------------------------
aldreneo
Tue May 02, 2006 9:58 pm

Return the output of a program
-----------------------------------
Is it possible to return the output of a program with sys?

-----------------------------------
Delos
Tue May 02, 2006 10:26 pm


-----------------------------------
Hi.  Rats live on no evil star.

Now, please be more specific in what you're asking.  Questions like yours are vague and unfulfilling.  They will get no useful answers.  None whatsoever.  What do you mean "the output".  What do you mean by "sys"?  Are you referring to Sys.Nargs() perhaps?
If you have specific code associated with this question, please either attach it or post it using [code] tags.

-----------------------------------
aldreneo
Wed May 03, 2006 4:01 pm


-----------------------------------
Ok....
How do I make it:

var command:string
get command
    if not Sys.Exec (command) as (var output:string)then
        put "Error"
    end if
put output

So that whatever program that is run it returns the output of the program into the string?

such as 


---EXAMPLE---
ping google.ca
Pinging google.com [64.233.187.99] with 32 bytes of data:

Reply from 64.233.187.99: bytes=32 time=55ms TTL=239
Reply from 64.233.187.99: bytes=32 time=101ms TTL=239
Reply from 64.233.187.99: bytes=32 time=118ms TTL=239
Reply from 64.233.187.99: bytes=32 time=108ms TTL=239

Ping statistics for 64.233.187.99:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 55ms, Maximum = 118ms, Average = 95ms
---END OF EXAMPLE---
[/code]

-----------------------------------
GlobeTrotter
Wed May 03, 2006 4:17 pm


-----------------------------------
I'm pretty sure that that is not directly possible.  You can probably do a workaround though.  There are system calls that write to a file, right?  So write that system call to a file and then use turing to open up the file it creates.

-----------------------------------
Tony
Wed May 03, 2006 4:21 pm


-----------------------------------
ok, so you want to read stdout of another program?

I don't think that's something that Turing does. Sys.Exec sends out a request to execute a command.

Your best bet is to ether pass a parameter to the program to output to a file instead (so you can read the file) or have it piped to a C or Java program that would save output to file.

-----------------------------------
codemage
Thu May 04, 2006 8:05 am


-----------------------------------
Heh.  Rats.  That's clever.

Stressed? No tips? Spit on desserts!
