Rubycookbook 15.1 problem

I was following along Lucas's rubycookbook receipe 15.1 for creating a
ROR application for displaying the o/p of dir command on a windows
machine onoto a browser.

my application is named "check" instead of "status" as given in
receipe.

my C:/Documents and
Settings/ri004902/check/app/controllers/check_controller.rb .. file
looks as
........................................................
class CheckController < ApplicationController
  def index
    time = Time.now
    @time = time
    @dr = exec "dir/p"
  end
end
......................................
and my C:\Documents and
Settings\ri004902\check\app\views\check\index.rhtml .. file is
...............................................................
<h1>Directory structure at <%= @time %></h1>
<p><%= @dr %></p>
.....................................................

I start the webbrick and point my brwser to
http://localhost:3000/check/

what i get is
Application error (Rails)

I tried with @dr= 'dir/p' in index of CheckController .. but in vain.

could anyone provide me a lead.

Cheers
Rajib

I don't know Rails all that well, but it strikes me as doubtful that you want:

    @dr = exec "dir/p"

which will _replace_ the executing ruby process with a new process (here running dir/p), and won't return. Maybe you'd want backticks instead:

  @dr = `dir/p`

Also, I'm not sure whether you mean `dir/p` or `dir /p`. In any event, note that those are backticks, not single quotes as you've already tried.

Hope that helps,

···

On Fri, 24 Nov 2006 12:55:34 -0000, <rajibsukanta@yahoo.co.in> wrote:
--
Ross Bamford - rosco@roscopeco.remove.co.uk

This could be irrelevant - I'm on Mac OS X, and there is no "dir"
command there - but OMM the example as printed doesn't work either,
because the single-quotes in the original should be backticks. The
recipe has:

@ps = 'ps aux'

But it should be:

@ps = `ps aux`

Perhaps you should try `dir/p` (whatever that may be) instead of using
exec? Just a guess... m.

···

<rajibsukanta@yahoo.co.in> wrote:

I was following along Lucas's rubycookbook receipe 15.1 for creating a
ROR application for displaying the o/p of dir command on a windows
machine onoto a browser.

my application is named "check" instead of "status" as given in
receipe.

my C:/Documents and
Settings/ri004902/check/app/controllers/check_controller.rb .. file
looks as
........................................................
class CheckController < ApplicationController
  def index
    time = Time.now
    @time = time
    @dr = exec "dir/p"
  end
end
......................................
and my C:\Documents and
Settings\ri004902\check\app\views\check\index.rhtml .. file is
...............................................................
<h1>Directory structure at <%= @time %></h1>
<p><%= @dr %></p>
.....................................................

I start the webbrick and point my brwser to
http://localhost:3000/check/

what i get is
Application error (Rails)

I tried with @dr= 'dir/p' in index of CheckController .. but in vain.

could anyone provide me a lead.

--
matt neuburg, phd = matt@tidbits.com, Matt Neuburg’s Home Page
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com

> I was following along Lucas's rubycookbook receipe 15.1 for creating a
> ROR application for displaying the o/p of dir command on a windows
> machine onoto a browser.

> my application is named "check" instead of "status" as given in
> receipe.

> my C:/Documents and
> Settings/ri004902/check/app/controllers/check_controller.rb .. file
> looks as
> ........................................................
> class CheckController < ApplicationController
> def index
> time = Time.now
> @time = time
> @dr = exec "dir/p"
> end
> end
> ......................................
> and my C:\Documents and
> Settings\ri004902\check\app\views\check\index.rhtml .. file is
> ...............................................................
> <h1>Directory structure at <%= @time %></h1>
> <p><%= @dr %></p>
> .....................................................

> I start the webbrick and point my brwser to
>http://localhost:3000/check/

> what i get is
> Application error (Rails)

> I tried with @dr= 'dir/p' in index of CheckController .. but in vain.

> could anyone provide me a lead.This could be irrelevant - I'm on Mac OS X, and there is no "dir"
command there - but OMM the example as printed doesn't work either,
because the single-quotes in the original should be backticks. The
recipe has:

@ps = 'ps aux'

But it should be:

@ps = `ps aux`

Perhaps you should try `dir/p` (whatever that may be) instead of using
exec? Just a guess... m.

Oh .. i thought that was right..now i tried with

class CheckController < ApplicationController
  def index
    time = Time.now
    @time = time
    @dr = ` dir `
  end
end

... but in vain still that " Application error (Rails)" is bugging me.

any lead?

btw .. what is the best way to debug rails application

thanks
rajib

···

On Nov 24, 8:44 pm, m...@tidbits.com (matt neuburg) wrote:

<rajibsuka...@yahoo.co.in> wrote:

--
matt neuburg, phd = m...@tidbits.com,Matt Neuburg’s Home Page
Tiger -http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript -http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart.http://www.tidbits.com- Hide quoted text -- Show quoted text -

shouldn't your class be called Check ? Not too sure about Rails and am a nood to Ruby so maybe I should just but out!! :frowning:

rajibsukanta <rajibsukanta@yahoo.co.in> wrote:

wrote:
> I was following along Lucas's rubycookbook receipe 15.1 for creating a
> ROR application for displaying the o/p of dir command on a windows
> machine onoto a browser.

> my application is named "check" instead of "status" as given in
> receipe.

> my C:/Documents and
> Settings/ri004902/check/app/controllers/check_controller.rb .. file
> looks as
> ........................................................
> class CheckController < ApplicationController
> def index
> time = Time.now
> @time = time
> @dr = exec "dir/p"
> end
> end
> ......................................
> and my C:\Documents and
> Settings\ri004902\check\app\views\check\index.rhtml .. file is
> ...............................................................
> Directory structure at <%= @time %>
> <%= @dr %>

> .....................................................

> I start the webbrick and point my brwser to
>http://localhost:3000/check/

> what i get is
> Application error (Rails)

> I tried with @dr= 'dir/p' in index of CheckController .. but in vain.

> could anyone provide me a lead.This could be irrelevant - I'm on Mac OS X, and there is no "dir"
command there - but OMM the example as printed doesn't work either,
because the single-quotes in the original should be backticks. The
recipe has:

@ps = 'ps aux'

But it should be:

@ps = `ps aux`

Perhaps you should try `dir/p` (whatever that may be) instead of using
exec? Just a guess... m.

Oh .. i thought that was right..now i tried with

class CheckController < ApplicationController
  def index
    time = Time.now
    @time = time
    @dr = ` dir `
  end
end

... but in vain still that " Application error (Rails)" is bugging me.

any lead?

btw .. what is the best way to debug rails application

thanks
rajib

···

On Nov 24, 8:44 pm, m...@tidbits.com (matt neuburg) wrote:

--
matt neuburg, phd = m...@tidbits.com,Matt Neuburg’s Home Page
Tiger -http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript -http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart.http://www.tidbits.com- Hide quoted text -- Show quoted text -

---------------------------------
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine