[Swift-devel] Assigning stdout to a string variable in Swift
Emalayan Vairavanathan
svemalayan at yahoo.com
Tue Apr 24 13:23:05 CDT 2012
Thank you Justin.
One more question. I wrote the following program to get the machine location using readData(). But the program fails saying "foo.txt (No such file or directory)". Do you see any obvious bugs in the code below? Could you please help me to get this working ?
type messagefile;
app (messagefile t) get_machine_via_file(string fileName) {
getIP fileName stdout=@filename(t);
}
app (messagefile t) print (string m) {
echo m stdout=@filename(t);
}
messagefile machine_location <simple_mapper;prefix="foo",suffix=".txt">;
messagefile output <simple_mapper;prefix="hoo",suffix=".txt">;
machine_location = get_machine_via_file("MyFile");
string s = readData(@filename(machine_location));
output= print(s);
________________________________
From: Justin M Wozniak <wozniak at mcs.anl.gov>
To: swift-devel at ci.uchicago.edu
Sent: Tuesday, 24 April 2012 10:19 AM
Subject: Re: [Swift-devel] Assigning stdout to a string variable in Swift
Hi Emalayan
The only meaningful output from an app function is in files. I suggest
you put the output in a file and read it with readData().
Justin
On 04/24/2012 12:16 PM, Emalayan Vairavanathan wrote:
> Hi All,
>
> Is it possible to assign a stdout to a string variable in Swift ?
>
> I need to get the IP of a machine by executing an shell script and then
> assign it to a string variable. Please see the sample code pasted below
> (Here the string variable is written to a file to verify program works
> correctly). But the program didn't make any progress and swift was
> repeatedly printing a message called "Initializing site shared
> directory:1" on the console.
>
> Any ideas ? Is this swift code is correct ? or swift does not support
> this feature ? In case if swift does not support this feature, is there
> a way to use the stdout without writing to a file ?
>
> Thank you
> Emalayan
>
> 1) Source code
>
> type messagefile;
>
> app (string machine) get_machine (string fileName) {
> getIP fileName stdout = machine;
> }
>
> app (messagefile t) printIP (string m) {
> echo m stdout=@filename(t);
> }
>
> string IP = get_machine("myFile")
> messagefile outfile <simple_mapper;prefix="foo",suffix=".txt">;
> outfile = printIP(IP);
>
> 2) Tc file:
>
> localhost cat /bin/cat null null null
> localhost echo /bin/echo null null null
> localhost getIP
> /home/emalayan/Workspace/Mosa_March_12/tools/synthaticBenchmark/swift-scripts/pipeline-loc-aware/wrappers/getIP.sh
> null null null
>
> 3)Site file:
>
> <config>
>
> <pool handle="localhost">
> <filesystem provider="local" />
> <execution provider="local" />
> <workdirectory>/home/emalayan/Mosa_March_12/tools/synthaticBenchmark/swift-scripts/pipeline-loc-aware/swift.work</workdirectory>
> <profile namespace="karajan" key="jobThrottle">0</profile>
> </pool>
>
> </config>
>
>
> 4) stdout:
>
> Swift 0.93 swift-r5483 cog-r3339
>
> RunID: 20120424-0950-tkdyv925
> Progress: time: Tue, 24 Apr 2012 09:50:45 -0700
> Progress: time: Tue, 24 Apr 2012 09:51:15 -0700 Initializing site shared
> directory:1
> Progress: time: Tue, 24 Apr 2012 09:51:45 -0700 Initializing site shared
> directory:1
> Progress: time: Tue, 24 Apr 2012 09:52:15 -0700 Initializing site shared
> directory:1
> Progress: time: Tue, 24 Apr 2012 09:52:45 -0700 Initializing site shared
> directory:1
> Progress: time: Tue, 24 Apr 2012 09:53:15 -0700 Initializing site shared
> directory:1
>
>
> _______________________________________________
> Swift-devel mailing list
> Swift-devel at ci.uchicago.edu
> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel
--
Justin M Wozniak
_______________________________________________
Swift-devel mailing list
Swift-devel at ci.uchicago.edu
https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-devel/attachments/20120424/a73370b9/attachment.html>
More information about the Swift-devel
mailing list