# Instance variable into call linux command

**URL:** <https://www.ruby-forum.com/t/instance-variable-into-call-linux-command/130345>\
**Category:** Ruby\
**Created:** [February 27, 2008, 3:12pm UTC](https://www.ruby-forum.com/t/instance-variable-into-call-linux-command/130345 "2008-02-27T15:12:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gugui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9de053/32.png) [@gugui](https://www.ruby-forum.com/u/gugui)\
**Post date:** [February 27, 2008, 3:12pm UTC](https://www.ruby-forum.com/t/instance-variable-into-call-linux-command/130345/1 "2008-02-27T15:12:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gugui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9de053/32.png) [@gugui](https://www.ruby-forum.com/u/gugui)\
**Post date:** [February 27, 2008, 3:17pm UTC](https://www.ruby-forum.com/t/instance-variable-into-call-linux-command/130345/2 "2008-02-27T15:17:32Z")

</div>

Hi.

> > @a = “joe”  
> > =\> “joe”
> 
> > `ls #{@a}`  
> > ls: joe: No such file or directory  
> > =\> “”
> 
> >

Use the string interpolation #{ruby code here}.

Arlen
