Ruby Noob Here! I'm trying to create and write to files in ruby using variables as the name of the files to be created. If I use a type the file name it work same with another variable #{system}, but the issue appears to be with a specific variable that is parsed early on. Error received- Errno::ENOENT: No such file or directory
array#record contains: Sun /log/schedule.log.20180617 Mon /log/schedule.log.20180618 Tue /log/schedule.log.20180619 Wed /log/schedule.log.20180620 Wed /log/schedule.log Section of code.
lines = record.split("\n") lines.each do |line| log = /(\/.*schedule.log(?:\.20[0-9]{6})?)/.match(line) @cmd = "grep DEBUG #{log} | grep \"start\\|running\"" rawdata = ssh.exec!(@cmd) logfile = File.new("#{system}_#{log}", 'w+') logfile.puts rawdata logfile.close end ssh.close OUTPUT Error received- Errno::ENOENT: No such file or directory - server1_schedule.log
Desired output should create a handful of log files with the naming convention <persystem_schedule.log<date>>.
foo/barwhenfoodoesn't exist.