instance variable into call linux command

Discussion in 'Ruby' started by Luiz Macchi, Feb 27, 2008.

  1. Luiz Macchi

    Luiz Macchi Guest

    Hi all,
    I need to call a Linux command from ruby app to print a text file ! so
    i´d like to put a instance variable (@printer_name) into the command
    !

    for example:

    def imprimir
    `lpr -P@printer_name /tmp/impressao.txt`
    end


    how to do this ? it dont recognize the variable...

    if i put the name of printer instead it runs

    thanks any help
    --
    Posted via http://www.ruby-forum.com/.
    Luiz Macchi, Feb 27, 2008
    #1
    1. Advertising

  2. Luiz Macchi

    Arlen Cuss Guest

    [Note: parts of this message were removed to make it a legal post.]

    Hi.

    >> @a = "joe"

    => "joe"
    >> `ls #{@a}`

    ls: joe: No such file or directory
    => ""
    >>


    Use the string interpolation #{ruby code here}.

    Arlen
    Arlen Cuss, Feb 27, 2008
    #2
    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. Gerry Sutton
    Replies:
    1
    Views:
    528
    Peter Otten
    Apr 16, 2005
  2. prakash
    Replies:
    2
    Views:
    575
    prakash
    Apr 11, 2005
  3. David Garamond
    Replies:
    5
    Views:
    227
    Ara.T.Howard
    Jun 8, 2004
  4. Leon Bogaert
    Replies:
    19
    Views:
    319
    Robert Klemme
    Mar 23, 2008
  5. Peng Yu
    Replies:
    3
    Views:
    348
    Rainer Weikusat
    May 13, 2013
Loading...

Share This Page