How do I change directories?

Hi,
How do I change directory from a Ruby program?

I tried ‘system(“cd #{dir}”)’ but it didn’t work.
There must be a way.

Thanks all,

···


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

Hi –

···

On Sun, 27 Apr 2003, Daniel Carrera wrote:

Hi,
How do I change directory from a Ruby program?

I tried ‘system(“cd #{dir}”)’ but it didn’t work.
There must be a way.

Dir.chdir

David


David Alan Black
home: dblack@superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

Daniel Carrera dcarrera@math.umd.edu writes:

How do I change directory from a Ruby program?

I tried ‘system(“cd #{dir}”)’ but it didn’t work.

Ruby has its own chdir; you don’t have to ask the system to cd.

puts Dir.getwd
Dir.chdir(dir)
puts Dir.getwd

I hope this helps,

Tim

Hi,
How do I change directory from a Ruby program?

I tried ‘system(“cd #{dir}”)’ but it didn’t work.
There must be a way.

Dir.chdir

Thanks.

···


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

And if you do, you spawn a shell which will chdir and exits
afterwards, leaving nothing done…

puts Dir.getwd
system(“cd #{dir}; pwd”)
puts Dir.getwd

Paul

···

On Sun, Apr 27, 2003 at 06:50:46AM +0900, Tim Heaney wrote:

Daniel Carrera dcarrera@math.umd.edu writes:

How do I change directory from a Ruby program?

I tried ‘system(“cd #{dir}”)’ but it didn’t work.

Ruby has its own chdir; you don’t have to ask the system to cd.


Student @ Eindhoven | JID: paul@luon.net
University of Technology, The Netherlands | email: paul@luon.net

Using the Power of Debian GNU/Linux <<< | GnuPG: finger paul@luon.net