Retrieve ruby script file name

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,

···

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

Yuguri Azuma 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__)

···

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

Thanks, Hugh.

Hugh Evans wrote:

···

Yuguri Azuma 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__)

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

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

···

On 05.04.2009 05:01, Hugh Evans wrote:

Yuguri Azuma 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__)

Hello Robert,

Thank you for the additional information.

Regards,
Yuguri

Robert Klemme wrote:

···

On 05.04.2009 05:01, Hugh Evans 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

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

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,

Hello Anil, does this help?:

cheers,
lasitha

···

On Mon, Apr 13, 2009 at 3:45 PM, <ext-golla.anil-kumar@nokia.com> 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.