From f23ea036711569222b6fbc4fb33aa2fd9783a961 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 26 Feb 2012 20:57:31 -0500 Subject: [PATCH] ex17 extra credit #2 --- ex17-ec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ex17-ec.rb diff --git a/ex17-ec.rb b/ex17-ec.rb new file mode 100644 index 0000000..8ed5ed2 --- /dev/null +++ b/ex17-ec.rb @@ -0,0 +1,23 @@ + +from_file, to_file = ARGV +script = $0 + +puts "Copying from #{from_file} to #{to_file}" + +# we could do these two on one line too, how? +input = File.open(from_file) +indata = input.read() + +puts "The input file is #{indata.length} bytes long" + +puts "Does the output file exist? #{File.exists? to_file}" +puts "Ready, hit RETURN to continue, CTRL-C to abort." +STDIN.gets + +output = File.open(to_file, 'w') +output.write(indata) + +puts "Alright, all done." + +output.close() +input.close()