Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Return the output of a program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
aldreneo




PostPosted: Tue May 02, 2006 9:58 pm   Post subject: Return the output of a program

Is it possible to return the output of a program with sys?
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue May 02, 2006 10:26 pm   Post subject: (No subject)

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




PostPosted: Wed May 03, 2006 4:01 pm   Post subject: (No subject)

Ok....
How do I make it:
code:

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

code:

---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




PostPosted: Wed May 03, 2006 4:17 pm   Post subject: (No subject)

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




PostPosted: Wed May 03, 2006 4:21 pm   Post subject: (No subject)

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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
codemage




PostPosted: Thu May 04, 2006 8:05 am   Post subject: (No subject)

Heh. Rats. That's clever.

Stressed? No tips? Spit on desserts!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: