Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

adding directory location to my file output script

20 views
Skip to first unread message

cross...@gmail.com

unread,
Oct 10, 2012, 4:04:35 PM10/10/12
to
Below is my script which create me a html file called pickle.html and then when ran again, it checks if exists and if so appends to the file and creates new one.

I need to tell the script where I want to the html file to go to.

I run this from the working directory and in the same directory is a folder called 'logs' so I would like all the pickle.html files to go to logs.

Suggestions? and Thank you much in advance!


require 'date'

file, new_file = 'pickle.html', DateTime.now.strftime('%s')

if File.exists?('file')
File.rename('file', "pickle_#{new_file}.html")
end

command = %Q(cucumber --format 'Timestamped::HtmlFormatter' --out #{file})

exec command

Charles Calvert

unread,
Oct 10, 2012, 9:41:32 PM10/10/12
to
On Wed, 10 Oct 2012 13:04:35 -0700 (PDT), cross...@gmail.com wrote
in <f5075c06-b7f2-4cd3...@googlegroups.com>:

> Below is my script which create me a html file called pickle.html
> and then when ran again, it checks if exists and if so appends to
> the file and creates new one.
>
> I need to tell the script where I want to the html file to go to.
>
> I run this from the working directory and in the same directory is
> a folder called 'logs' so I would like all the pickle.html files
> to go to logs.

[snip]

>require 'date'
>
>file, new_file = 'pickle.html', DateTime.now.strftime('%s')

How about:

file, new_file = 'logs/pickle.html', DateTime.now.strftime('%s')

>if File.exists?('file')

Why are you enclosing file in quotation marks? That's a string
literal, not a variable name.

> File.rename('file', "pickle_#{new_file}.html")

File.rename(file, "logs/pickle_#{new_file}.html")

[snip rest]
--
Charles Calvert | Websites
Celtic Wolf, Inc. | Web Applications
http://www.celticwolf.com/ | Software
(703) 580-0210 | Databases

Ryan Crossan

unread,
Oct 11, 2012, 9:32:13 AM10/11/12
to
Charles,

Thank you much for the tips and suggestions. It is working just like I need it to now.

I appreciate it.

- Ryan
0 new messages