Problem ruby pwd in different directory

Hi my problem is this

i have a script in direcory ex

c:\temp\pippo.rb

this script have this code

a= Dir.pwd()
puts a

if i exec a script from another directory there is a problem. The script
write a path of ruby exec and not the path of script ex

c:\nano\ruby ..\temp\pippo.rb

=> c:\nano

i want

=> c:\temp

Can you help me???

Thank you in advance!

···

--
Posted via http://www.ruby-forum.com/.

Dir.pwd gives the current working directory. To get the directory of
the script you are running you can use File.dirname(__FILE__)

···

On Fri, May 14, 2010 at 1:30 PM, Gianluca Rettore <gladenko@gladenko.com> wrote:

Hi my problem is this

i have a script in direcory ex

c:\temp\pippo.rb

this script have this code

a= Dir.pwd()
puts a

if i exec a script from another directory there is a problem. The script
write a path of ruby exec and not the path of script ex

c:\nano\ruby ..\temp\pippo.rb

=> c:\nano

i want

=> c:\temp

Can you help me???

--
Luis Parravicini
http://ktulu.com.ar/blog/

Hi, not entirely sure why you need the directory the same as the file, but
every time I've needed that, it had to do with relative positioning of
files. If that's the case for you, then you might check out this blog entry,
which I found pretty helpful

···

On Fri, May 14, 2010 at 11:30 AM, Gianluca Rettore <gladenko@gladenko.com>wrote:

Hi my problem is this

i have a script in direcory ex

c:\temp\pippo.rb

this script have this code

a= Dir.pwd()
puts a

if i exec a script from another directory there is a problem. The script
write a path of ruby exec and not the path of script ex

c:\nano\ruby ..\temp\pippo.rb

=> c:\nano

i want

=> c:\temp

Can you help me???

Thank you in advance!
--
Posted via http://www.ruby-forum.com/\.

Luis Parravicini wrote:

···

On Fri, May 14, 2010 at 1:30 PM, Gianluca Rettore > <gladenko@gladenko.com> wrote:

=> c:\temp

Can you help me???

Dir.pwd gives the current working directory. To get the directory of
the script you are running you can use File.dirname(__FILE__)

Yessss Thank you very much! now is all ok!

:smiley:

--
Posted via http://www.ruby-forum.com/\.