How to append the time stamp in before file name

Hello all,

i write code for create log file and i want to append the time stamp
before file name.
like: 0513_1552_05.logger.txt

plz help me......!!!!!!!!!

require 'watir'
include Watir
require 'logger'
time_stamp_s = Time.new.strftime('%m%d_%H%M_%S')
puts time_stamp_s
a="logger.txt"
log = Logger.new( 'C:\test\#{time_stamp_s}'+'.txt', 'daily' )
        if(
ie=Watir::IE.start("http://vision.vendormate.net/vm/login.do"))
                    if(ie.contains_text("Login"))
                          log.debug "login page open
successfully...!!!!!!!"
                    else
                          log.debug "login page not found.....!!!!"
                          break
                    end
        end
        if(contents = File.read("c:/test/test.txt"))
              log.debug "Read text file test.txt"
        else
              log.debug "File not avilable"
              break
        end
data = contents.map do |line|
         line.chomp.split("=")[1]
end
        if(ie.text_field(:name,"userId").set(data[0]))
              log.debug "fill the username in username text field"
        else
              log.debug "username not avilable"
        end

        if(ie.text_field(:name,"password").set(data[1]))
              log.debug "fill the password in password text field"
        else
              log.debug "Password not avilable"
        end
ie.button(:name,"Submit").click()
if(ie.contains_text("My statistics"))
     log.debug "Login Successfully.......!!!\n"
   else
     log.debug "Login Failed....!!!!!!\n"
end

···

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

Hi

···

On Thu, May 13, 2010 at 7:31 AM, KingMaker KingMaker <sweetzubair@gmail.com> wrote:

i write code for create log file and i want to append the time stamp
before file name.
like: 0513_1552_05.logger.txt

plz help me......!!!!!!!!!

require 'watir'
include Watir
require 'logger'
time_stamp_s = Time.new.strftime('%m%d_%H%M_%S')
puts time_stamp_s
a="logger.txt"
log = Logger.new( 'C:\test\#{time_stamp_s}'+'.txt', 'daily' )

You get string interpolation when using double quotes. See for other
cases Ruby | zenspider.com | by ryan davis
So try with "C:\test\#{time_stamp_s}.txt"

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