<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I've committed the change for running the strings under bash, and
wildcards <br>
and pipes are working. I can now do bash one-liners neatly and I
like that.<br>
<br>
I tested with this :<br>
string o[] = system("ls *.swift");<br>
foreach t,i in o{<br>
tracef("o=%s\n",o[i]);<br>
}<br>
<br>
RunID: run021<br>
Progress: Sat, 05 Apr 2014 22:49:15-0500<br>
o=fail.swift<br>
o=system.swift<br>
o=shell.swift<br>
o=t.swift<br>
Final status:Sat, 05 Apr 2014 22:49:15-0500<br>
<br>
while system("echo *.swift"); returns a single line which goes to
tracef.<br>
Like this :<br>
RunID: run022<br>
Progress: Sat, 05 Apr 2014 22:50:12-0500<br>
o=fail.swift shell.swift system.swift t.swift<br>
Final status:Sat, 05 Apr 2014 22:50:12-0500<br>
<br>
-Yadu<br>
<br>
<div class="moz-cite-prefix">On 04/05/2014 08:11 PM, Michael Wilde
wrote:<br>
</div>
<blockquote cite="mid:5340A9B9.6000303@anl.gov" type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<br>
As I alluded to in a prior post (but didnt say clearly), Im in
favor of giving system a varying number of returns, something
like:<br>
<br>
output = system("command");<br>
(output,error) = system("command");<br>
(output,error,rc) = system("command");<br>
<br>
Also letting output and error be either strings or string arrays.<br>
<br>
Not sure how much flexibility is best, though.<br>
<br>
Regarding treating function failures like app failures: I dont
think thats good in the case of functions. Further, in the case
of apps, we have at least one user request to provide more
flexible error handling for app failures. So when the user
requests an rc (from either), any non-zero RC should be returned
to the user and not cause the function (app or built-in) to be
considered failed. Null files can be returned to preserve dataflow
semantics. This is not totally clear, and not clearly "best", but
should should consider it.<br>
<br>
Yadu, regarding the current implementation: I was about to send a
note to swift-user when I decided to test it first. Im getting
strange errors when I try to do:<br>
<br>
string o[] = system("echo *.swift");<br>
tracef("o=%s\n",o[0]);<br>
# produces:<br>
o=*.swift<br>
<br>
string o[] = system("sh -c 'echo *.swift'");<br>
tracef("o=%s\n",o[0]);<br>
<br>
# produces:<br>
swift:system returned exitcode :1<br>
swift:system stderr:<br>
*.swift': -c: line 0: unexpected EOF while looking for matching
`''*.swift': -c: line 1: syntax error: unexpected end of file<br>
<br>
Execution failed:<br>
java.lang.IndexOutOfBoundsException: Invalid index [0] for o<br>
tracef @ system, line: 28<br>
Caused by: java.lang.IndexOutOfBoundsException: Invalid index [0]
for o<br>
<br>
---<br>
<br>
Yet:<br>
string o[] = system("sh -c 'date'");<br>
tracef("o=%s\n",o[0]);<br>
# produces:<br>
o=Sat Apr 5 20:08:29 CDT 2014<br>
<br>
So something strange is happening when I try to pass an argument
with shell wildcard chars to "sh -c".<br>
<br>
I think that system( ) by default should send its args to "sh -c"
so that wildcards and all related shell features are available.<br>
<br>
Lastly, note that in above, "echo" is just an experiment; what I
really want to do in this example is "/bin/ls -1 *.swift" for
example.<br>
<br>
- Mike<br>
<br>
<br>
<div class="moz-cite-prefix">On 4/5/14, 7:01 PM, Yadu Nand Babuji
wrote:<br>
</div>
<blockquote cite="mid:53409969.5080604@uchicago.edu" type="cite">
Ketan,<br>
<br>
Do we need that ? If you add stdout, stderr and say exitcode as
returns, the user has no <br>
choice but to define variables to hold those return values.<br>
<br>
Mihael mentioned in a separate thread that the behavior should
be to fail early in case the<br>
executed string returns a non-zero exitcode.<br>
<br>
-Yadu<br>
<br>
<div class="moz-cite-prefix">On 04/04/2014 10:58 PM, Ketan
Maheshwari wrote:<br>
</div>
<blockquote
cite="mid:CAMUuvioi7zWpdbGf7s9HbrWmMi=NjZstcYP-Zj8449vCoG1m1A@mail.gmail.com"
type="cite">
<div dir="ltr">Is it possible to handle stdout and/or stderr
of system("command") separately? That way, it might be
useful in other places as well.</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Fri, Apr 4, 2014 at 12:08 PM,
Yadu Nand <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:yadudoc1729@gmail.com" target="_blank">yadudoc1729@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have just added a new builtin "system" to trunk. It
takes a string,<br>
which is executed in the shell<br>
by java and the results are returned as an array. This
is done to make<br>
mappings easier, for example,<br>
you can map an entire folder "foo" using the following :<br>
<br>
file folder[ ] < array_mapper; files = system ("find
foo -type f") >;<br>
<br>
If the execution of the string provided fails, the
logger would report<br>
the the exitcode and stderr to<br>
the swift stdout.<br>
<br>
Thanks,<br>
Yadu Nand B<br>
_______________________________________________<br>
Swift-devel mailing list<br>
<a moz-do-not-send="true"
href="mailto:Swift-devel@ci.uchicago.edu">Swift-devel@ci.uchicago.edu</a><br>
<a moz-do-not-send="true"
href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel"
target="_blank">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Swift-devel mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Swift-devel@ci.uchicago.edu">Swift-devel@ci.uchicago.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel</a>
</pre>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Swift-devel mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Swift-devel@ci.uchicago.edu">Swift-devel@ci.uchicago.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Michael Wilde
Mathematics and Computer Science Computation Institute
Argonne National Laboratory The University of Chicago
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Swift-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Swift-devel@ci.uchicago.edu">Swift-devel@ci.uchicago.edu</a>
<a class="moz-txt-link-freetext" href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>