I'm running Ruby on Ubuntu Linux, and I need to be able to get the
current directory that the program is running in into a variable in my
program. Is there a simple way to do this? Also, is there a way to
change directories within the program?
Thanks....
I'm running Ruby on Ubuntu Linux, and I need to be able to get the
current directory that the program is running in into a variable in my
program. Is there a simple way to do this? Also, is there a way to
change directories within the program?
Thanks....
Check out the Dir class, particularly Dir.pwd and Dir.chdir,
Thanks Tim. the Dir.pwd is exactly what I need. I haven't figured out
how to use the Dir.chdir yet, but that looks promising too.
PV
Tim Hunter wrote:
···
Peter Vanderhaden wrote:
I'm running Ruby on Ubuntu Linux, and I need to be able to get the
current directory that the program is running in into a variable in my
program. Is there a simple way to do this? Also, is there a way to
change directories within the program?
Thanks....
Check out the Dir class, particularly Dir.pwd and Dir.chdir,
p Dir.entries(".") #array containing files in current directory
puts
Will this work on Windows, too? Or is the "." a Linux specific thing? If
it doesn't work on Windows, how can I get the absolute path of the
scipt? Thanks!
Using Dir.chdir() I have no problem changing to directories created by
my rails application, however, I can't get it to change to a directory
that I made. I tried adding "config.load_paths += %W(
#{RAILS_ROOT}/public/my_new_folder" to my environment.rb file, but it
didn't work. When should I be using config.load_paths?