Sajeesh Krishnan
Sajeesh Krishnan

Reputation: 59

In Ruby when I pass a file to a variable

What I am trying to do :

date = `date +%Y%m%d`
Path = "/home/sajeesh/jam_#{date}"

if File.file?(Path)

      watch_for(Path, /FATAL/)

    else 

      exit 1
end

So when I do the condition; instead of jam_20170508 its taking jam_#{date} and its exiting; any possible workaround for this.

Thanks!

Upvotes: 0

Views: 41

Answers (1)

Wand Maker
Wand Maker

Reputation: 18762

There seems to be new line in Path.

Try using

Path = "/home/sajeesh/jam_#{date}".strip

Upvotes: 2

Related Questions