mardi 4 août 2015

How to implement sudo su in Ruby script?

I have sudo access to oracle user being non_root user (say guest_admin user). I need to login as oracle user to run some steps but my ruby script is failing at the very first step i.e., sudoing as oracle. Below is the piece of code.

require "java"
require "highline/import"
require "rubygems"
require 'rvm/capistrano'

curr =  File.expand_path(File.dirname(__FILE__))
$LOAD_PATH << curr  unless $LOAD_PATH.include? curr

system "sudo su - oracle"

I am getting the following error:

ruby test.rb

$rvm_path (/usr/local/rvm/scripts/rvm) does not exist.
/usr/local/rvm/scripts/rvm: line 171: __rvm_teardown: command not found
stty: standard input: Invalid argument
stty: standard input: Invalid argument

Can somebody help me fixing this? It's a show-stopper for me right now.

I tried to move require 'rvm/capistrano' at the end of the file but that dint help much.

Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire