irb(main):014:0> %x(echo "sdfsd") => "sdfsd\n" irb(main):015:0> system('echo "sdfsd"') sdfsd => true irb(main):016:0> `echo "sdfsd"` => "sdfsd\n"system() gives you a shell, but doesn't save the output. Backticks and %x are equivalent: they give you a shell environment and return the stdout output.
In puppet if you're using Resolution.exec:
Facter::Util::Resolution.exec('echo "sdfsd"')Things are not so obvious. Depending on the puppet version, you might get a shell environment and puppet is also doing some checking with 'which' that might result in a 'nil' return if your command is not a simple binary.
2 comments:
Actually %x() and the backtick are the same. Try %x(echo "sdfsh")
Thanks for the correction. My mistake was in thinking it needed a quoted string. Updated the post.
Post a Comment