I want to invoke a shell command from within ruby but as another user in
a Linux environment. I start the ruby script itself as root and in the
script I do something like this:
%x{su some_user -c “some_command”}
some_more_ruby_stuff
The problem is: ‘some_command’ gets successfully executed, but the ruby
script seems to never return to normal operation. ‘some_more_ruby_stuff’
gets never executed.
Could anyone tell me why this happens and maybe what I could do about
it?
The problem is: ‘some_command’ gets successfully executed, but the ruby
script seems to never return to normal operation. ‘some_more_ruby_stuff’
gets never executed.
Could anyone tell me why this happens and maybe what I could do about it?
Regards,
Moritz
It works just fine here. I tried running this:
puts %x{su wvdschel -c "whoami"}
puts "test"
which worked just fine:
root@wvdschel-laptop:~# ruby test
wvdschel
test
Are you sure your command returns? Maybe it blocks until the process
ends? Is there any information you could give on the command you are
trying to execute?
Wim
–
Wim Vander S.
Bachelor Computer Science, University Ghent