command interpretation

Discussion in 'Ruby' started by Martin Krischik, May 7, 2007.

  1. Hallo,

    I searched high and low to find how "command interpretation" actually
    works. But all I found is [1]:

    `echo command interpretation with interpolation and backslashes`
    %x(echo command interpretation with interpolation and backslashes)

    Now, this does not explain what kind of interpolation is done and more
    importantly: How to switch interpolation off.

    Background: I use ruby on the vms operating system and I want to run the
    following test command:

    x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´

    But all I get is:

    test.ruby:8: warning: parenthesize argument(s) for future version
    test.ruby:8: parse error
    x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    ^
    From which I deduct that some "magic" is done with the $ character
    which I don't want.

    Martin
    [1]
    http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals#Interpolation
    --
    Martin Krischik
    Martin Krischik, May 7, 2007
    #1
    1. Advertising

  2. On 07.05.2007 12:43, Martin Krischik wrote:
    > Hallo,
    >
    > I searched high and low to find how "command interpretation" actually
    > works. But all I found is [1]:
    >
    > `echo command interpretation with interpolation and backslashes`
    > %x(echo command interpretation with interpolation and backslashes)
    >
    > Now, this does not explain what kind of interpolation is done and more
    > importantly: How to switch interpolation off.
    >
    > Background: I use ruby on the vms operating system and I want to run the
    > following test command:
    >
    > x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    >
    > But all I get is:
    >
    > test.ruby:8: warning: parenthesize argument(s) for future version
    > test.ruby:8: parse error
    > x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    > ^
    > From which I deduct that some "magic" is done with the $ character
    > which I don't want.
    >
    > Martin
    > [1]
    > http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals#Interpolation


    Use system with multiple arguments. I think that should help.

    robert
    Robert Klemme, May 7, 2007
    #2
    1. Advertising

  3. On Mon, May 07, 2007 at 07:45:05PM +0900, Martin Krischik wrote:
    > Background: I use ruby on the vms operating system and I want to run the
    > following test command:
    >
    > x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    >
    > But all I get is:
    >
    > test.ruby:8: warning: parenthesize argument(s) for future version
    > test.ruby:8: parse error
    > x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    > ^
    > From which I deduct that some "magic" is done with the $ character
    > which I don't want.


    In the mail you sent, I saw character \264 (octal) where there should be a
    backtick. A backtick is \140 (octal), \x60 (hex), 96 (decimal)

    Have you tried using %x(...) instead?
    Brian Candler, May 7, 2007
    #3
  4. Martin Krischik

    Ken Bloom Guest

    On Mon, 07 May 2007 12:43:19 +0200, Martin Krischik wrote:

    > Hallo,
    >
    > I searched high and low to find how "command interpretation" actually
    > works. But all I found is [1]:
    >
    > `echo command interpretation with interpolation and backslashes`
    > %x(echo command interpretation with interpolation and backslashes)
    >
    > Now, this does not explain what kind of interpolation is done and more
    > importantly: How to switch interpolation off.
    >
    > Background: I use ruby on the vms operating system and I want to run the
    > following test command:
    >
    > x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    >
    > But all I get is:
    >
    > test.ruby:8: warning: parenthesize argument(s) for future version
    > test.ruby:8: parse error
    > x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    > ^
    > From which I deduct that some "magic" is done with the $ character
    > which I don't want.


    What kind of quote is a ´ ? It doesn't work out to be a backquote when I
    view it on my Linux system. Unlike perl and the shell, the $ isn't used
    for any magic in Ruby strings. (The #{} syntax is used instead.) The
    interpreter has decided to parse this as a function call within Ruby, and
    I'm guessing that's because your quotes aren't quotes.

    --Ken

    --
    Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
    Department of Computer Science. Illinois Institute of Technology.
    http://www.iit.edu/~kbloom1/
    Ken Bloom, May 7, 2007
    #4
  5. Brian Candler schrieb:

    > On Mon, May 07, 2007 at 07:45:05PM +0900, Martin Krischik wrote:
    >> Background: I use ruby on the vms operating system and I want to run the
    >> following test command:
    >>
    >> x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    >>
    >> But all I get is:
    >>
    >> test.ruby:8: warning: parenthesize argument(s) for future version
    >> test.ruby:8: parse error
    >> x = ´WRITE SYS$OUTPUT F$TRNLNM("SOURCE")´
    >> ^
    >> From which I deduct that some "magic" is done with the $ character
    >> which I don't want.

    >
    > In the mail you sent, I saw character \264 (octal) where there should be a
    > backtick. A backtick is \140 (octal), \x60 (hex), 96 (decimal)


    Another good reason to retire back ticks.

    > Have you tried using %x(...) instead?


    Indeed that works - thanks!

    Martin
    --
    Martin Krischik
    Martin Krischik, May 8, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wallclimber
    Replies:
    3
    Views:
    542
    Wallclimber
    May 26, 2004
  2. Thomas Thorsen
    Replies:
    2
    Views:
    5,300
    Thomas Thorsen
    Mar 18, 2006
  3. Replies:
    0
    Views:
    751
  4. tupolev
    Replies:
    2
    Views:
    3,877
    tupolev
    Jun 30, 2003
  5. aSchwarzie
    Replies:
    6
    Views:
    2,448
    aSchwarzie
    Nov 25, 2003
Loading...

Share This Page