From: Robert Klemme Date: 2009-04-05T16:49:28+09:00 Subject: Re: retrieve ruby script file name 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__) 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