adding directory location to my file output script

C

crossanpdx

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
 
C

Charles Calvert

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]
 
R

Ryan Crossan

Charles,

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

I appreciate it.

- Ryan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top