hi Maumita,
You can use following code to create the directory. This will create
the directory if it's not there.:

 Dir.mkdir(directory_path) if !File.exist( directory_path )

Also check ruby documentation (http://www.ruby-doc.org/core/classes/
Dir.html#M002318) if default permission doesnot work.
cheers



On Sep 7, 11:26 am, Maumita <maumita.majum...@gmail.com> wrote:
> Hi,
>
> To store watir output results in a directory,how I will create the
> directory whenre I want to store the results from watir script. Also
> the script will run in every hour and daily basis. So all results
> should get stored in the same directory.
>
> How can i do this.
>
> Below is my script -
> #Load the library and create reference to Library object
> require 'watir' #watir Controller
> require 'logger'
>
> # Ruby Logger
> # Logger is configured to write
> class Logger
>   # hack format of logger
>   class Formatter
>     #original: Format = "%s, [%s#%d] %5s -- %s: %s\n"
>     Formato = "[%s] [%5s] : %s\n"
>
>     def call(severity, time, progname, msg)
>       #add logging to stdout
>       puts output_message = msg2str(msg)
>       STDOUT.flush
>       #original: Format % [severity[0..0], format_datetime(time), $$,
> severity, progname, msg2str(msg)]
>       Formato % [format_datetime(time),severity, output_message]
>     end
>   end
> end
>
> #Create a log file
> time = Time.now.strftime("%Y-%m-%d")
> logfile = File.join('d:/ruby/log', "DportalMonitor_#{time}.csv")
> $log = Logger.new(logfile,'daily')
> $log.level = Logger::INFO
> $log.datetime_format = "%Y-%m-%d %H:%M:%S"
> $log.info("Started.")
>
> In the script I have mentioned the directory path. I want to create it
> automatically on others machine.
>
> Its urgent.Please reply as soon as possible.
>
> Thanks
> Maumita
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to