Unable to cat Ruby blocks to files
https://stackoverflow.com/questions/236713
Solution
You need to quote the interpolated parameter:
system("cat > test_file << \"#{a}\"")
And, cat is expecting a filename, not some text to append to test_file, so, this would work as I think you intended:
system("echo \"#{a}\" >> test_file")
If you want to do this in pure Ruby let me know and I'll give you an example.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow