mcv
mcv

Reputation: 175

How to execute and capture stdout of external command in Ruby using system() without shell escaping?

I can call system("echo", "''"), and this won't be interpreted by a shell. I'll have expected result: '' on stdout. But I need to capture this output. %x is not an option, since I don't want to run shell, but execute command directly (and I don't want to do shell escaping).

Upvotes: 5

Views: 4568

Answers (1)

Reese Moore
Reese Moore

Reputation: 11640

Use IO::popen (API link)
Slightly More In Depth Explanation

Upvotes: 3

Related Questions