# Capistrano: saving a result on var

**URL:** <https://www.ruby-forum.com/t/capistrano-saving-a-result-on-var/181743>\
**Category:** Ruby\
**Created:** [January 17, 2010, 4:11pm UTC](https://www.ruby-forum.com/t/capistrano-saving-a-result-on-var/181743 "2010-01-17T16:11:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/258eb7/32.png) [@botp](https://www.ruby-forum.com/u/botp)\
**Post date:** [January 17, 2010, 4:11pm UTC](https://www.ruby-forum.com/t/capistrano-saving-a-result-on-var/181743/1 "2010-01-17T16:11:15Z")

</div>

Hi All,  
sorry if this dumb and not pure ruby q, but i just hit a bump on  
capistrano.

how does one get a result of a run or sudo?

eg,

task :testing do  
x = run “date”  
p x  
end

it runs without error but i get nothing (nil ie) from x

kind regards -botp

---

<div class="post-metadata">

**Author:** ![botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/258eb7/32.png) [@botp](https://www.ruby-forum.com/u/botp)\
**Post date:** [January 17, 2010, 4:20pm UTC](https://www.ruby-forum.com/t/capistrano-saving-a-result-on-var/181743/2 "2010-01-17T16:20:01Z")

</div>

Hello botp,

> task :testing do  
> x = run “date”  
> p x  
> end
> 
> it runs without error but i get nothing (nil ie) from x

Use backstiks:

> > x = `date`  
> > =\> “Sun Jan 17 16:18:45 CET 2010\n”
> 
> > p x  
> > “Sun Jan 17 16:18:45 CET 2010\n”  
> > =\> nil

Cheers,

---

<div class="post-metadata">

**Author:** ![botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/258eb7/32.png) [@botp](https://www.ruby-forum.com/u/botp)\
**Post date:** [January 17, 2010, 4:36pm UTC](https://www.ruby-forum.com/t/capistrano-saving-a-result-on-var/181743/3 "2010-01-17T16:36:59Z")

</div>

On Sun, Jan 17, 2010 at 11:09 PM, botp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> sorry if this dumb and not pure ruby q, but i just hit a bump on capistrano.  
> …

pls ignore.

i found #capture and #stream

sorry for the noise

kind regards -botp

---

<div class="post-metadata">

**Author:** ![botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/258eb7/32.png) [@botp](https://www.ruby-forum.com/u/botp)\
**Post date:** [January 17, 2010, 6:19pm UTC](https://www.ruby-forum.com/t/capistrano-saving-a-result-on-var/181743/4 "2010-01-17T18:19:59Z")

</div>

On Sunday 17 January 2010 09:19:17 am Jean-Julien F. wrote:

> > > x = `date`
> 
> =\> “Sun Jan 17 16:18:45 CET 2010\n”

I don’t know why you’d want to run ‘date’ instead of Time.now from  
within  
Ruby, but the one reason I can think of is that Capistrano’s #run isn’t  
the  
equivalent of #system – it runs a command on the remote system. I’m  
guessing  
the point here is to do something with the remote system’s date,  
specifically.  
In that case, `date` is useless, as backticks run commands locally.
