0

Here's the script:

#!/usr/bin/env ruby

CODES = {}
puts "ok"

Under root user everything is fine:

# ./test.rb
ok

When munin's default interpreter is /bin/false nothing is happpening:

# su munin -c ./test.rb

When default interpreter is /bin/sh, it is always being used:

# su munin -c ./test.rb
./test.rb: line 3: CODES: command not found

Why under munin user Linux ignores the interpreter line from the script, while under root it works as usual?

Update. Finally it just started to work without any intentional fix from me.

Pavel Koryagin
  • 255
  • 1
  • 3
  • 8

1 Answers1

1

#! is interpreted by shell and if you not specify what shell you need by -s SHELL then it is default shell - /bin/false in you case. And false not understand #! syntax (in fact - not read you script at all). Use -s /bin/sh with su and it will work as you want.

dsznajder
  • 547
  • 4
  • 13
  • Munin itself will run the script with default interpreter. When default for its user is `/bin/sh` it tries to run the Ruby script as his own script. – Pavel Koryagin Mar 22 '13 at 07:03
  • @PavelKoryagin This part I don't understand - only good explanation for me is space between # and ! or on start of line, but it is obviously not a case because it works without su. Anyway - glad to hear it works for you now. – dsznajder Mar 22 '13 at 08:24