I'm trying to write a script that will take the output of a system
command and assign it to a variable whether it be a string, or array for
later processing. The following block:
On Thu, Dec 5, 2013 at 6:12 PM, Philip D. <lists@ruby-forum.com> wrote:
Hello,
I'm trying to write a script that will take the output of a system
command and assign it to a variable whether it be a string, or array for
later processing. The following block:
From the IRB responses, it looks like the command "python -V" is
printing the output and returning an empty string, I don't think there's
anything wrong with your code, it's how "python -V" responds.
Of course, someone else may have a better understanding of this.
On Thu, Dec 5, 2013 at 6:12 PM, Philip D. <lists@ruby-forum.com> wrote:
Hello,
I'm trying to write a script that will take the output of a system
command and assign it to a variable whether it be a string, or array for
later processing. The following block:
From the IRB responses, it looks like the command "python -V" is
printing the output and returning an empty string, I don't think there's
anything wrong with your code, it's how "python -V" responds.
Of course, someone else may have a better understanding of this.
Edit: Nice catch as usual, Robert! I thought that command was getting
through, since you can see the response given: "Python 3.3.2"
Thank you for that information, it definitely sheds some light on that
whole bit. I wouldn't have known what to search for to find that out.
Justin Collins wrote in post #1129754:
···
On 12/05/2013 09:20 AM, Robert Klemme wrote:
=> "C:/python/python332"
Certainly you can nest string interpolation, although it's silly in this
case (and most cases I've seen):
Thank you Justin, yes, I use the nested interpolation to help with the
commands and save code, but I will look into the Open3 and see what I
can do with that. Thank you for the help. I'll post back once I figure
out what I need to do.
Thank you for correcting me! I was too quickly glancing over the
expression and apparently overlooked the double quotes. And, yes, I
agree: if nesting is necessary than string interpolation is probably
not the best approach.
Cheers
robert
···
On Thu, Dec 5, 2013 at 7:54 PM, Justin Collins <justincollins@ucla.edu> wrote:
On 12/05/2013 09:20 AM, Robert Klemme wrote:
On Thu, Dec 5, 2013 at 6:12 PM, Philip D. <lists@ruby-forum.com> wrote:
You cannot nest string interpolation. Try
Certainly you can nest string interpolation, although it's silly in this case (and most cases I've seen):
Thank you Justin, yes, I use the nested interpolation to help with the
commands and save code, but I will look into the Open3 and see what I
can do with that. Thank you for the help. I'll post back once I figure
out what I need to do.
Just to be totally explicit, these are equivalent:
`#{"ruby -v"}` is the same as `ruby -v`
`#{"#{location}/python -V"}` is the same as `#{location}/python -V`