BrainLikeADullPencil
BrainLikeADullPencil

Reputation: 11673

` (backtick) is unexpected token

I'm doing some command line executions I learned in this blog post such as system or IO.popen on the file, and am getting errors.

Why is the backtick appearing, what does it mean, and how do I continue? Please explain.

 system('./err.rb')
-bash: syntax error near unexpected token `'./err.rb''

Similarily, when I run IO.popen:

output = IO.popen('./err.rb')
-bash: syntax error near unexpected token `('

Upvotes: 3

Views: 567

Answers (2)

sawa
sawa

Reputation: 168249

Whether in Ruby or bash, `...' is a meta expression used in places like error messages to quote the problematic part of the code. For example, in your error message: unexpected token `(', the problematic part is (. Backtick itself has nothing to do with the error.

Upvotes: 2

hammar
hammar

Reputation: 139930

That's not ruby you're typing things into, it's your shell bash. Assuming you've got ruby installed properly, type irb to get a ruby prompt and you should be able to proceed from there.

Upvotes: 7

Related Questions