Retrieve ruby script file name


#1

Hello Group,

Is there any way to retrieve the file name of the script that you are
executing?
For example if you have a ruby script named kitty.rb :

$./kitty.rb
script name is ‘kitty.rb’

Thank you,


#2

Yuguri A. wrote:

Hello Group,

Is there any way to retrieve the file name of the script that you are
executing?
For example if you have a ruby script named kitty.rb :

$./kitty.rb
script name is ‘kitty.rb’

Thank you,

puts File.basename(FILE)


#3

Thanks, Hugh.

Hugh E. wrote:

Yuguri A. wrote:

Hello Group,

Is there any way to retrieve the file name of the script that you are
executing?
For example if you have a ruby script named kitty.rb :

$./kitty.rb
script name is ‘kitty.rb’

Thank you,

puts File.basename(FILE)


#4

On 05.04.2009 05:01, Hugh E. wrote:

Thank you,

puts File.basename(FILE)

Note that there is $0 as well. FILE will contain the name of the
file which contains the currently executed line of code while $0 will
contain the name of the script that the interpreter was started with.
When requiring and loading other files FILE and $0 will point to
different names.

Kind regards

robert


#5

Hello Robert,

Thank you for the additional information.

Regards,
Yuguri

Robert K. wrote:

On 05.04.2009 05:01, Hugh E. wrote:

Thank you,

puts File.basename(FILE)

Note that there is $0 as well. FILE will contain the name of the
file which contains the currently executed line of code while $0 will
contain the name of the script that the interpreter was started with.
When requiring and loading other files FILE and $0 will point to
different names.

Kind regards

robert


#6

Hi,
I want to write a seperated module which contains all common functions
in file say common.rb
And I want to use these functions in my ruby script.
How can I achive these, can anybody help me in this regard.

Thanks,
Anil kumar,


#7

On Mon, Apr 13, 2009 at 3:45 PM, removed_email_address@domain.invalid
wrote:

Hi,
I want to write a seperated module which contains all common functions in file say common.rb
And I want to use these functions in my ruby script.

Hello Anil, does this help?:
http://is.gd/s8YV

cheers,
lasitha