Other than requiring the user to invoke a ruby script through sudo, is there a way to start running a script as a regular user, then at some point during runtime, elevate privileges to root, by prompting the user for their root password?
Maybe something along the lines of #exec using the current command prefixed with sudo?
This works. It just uses exec to call itself (
test_scriptin this case) again. But be very careful to make sure that it doesn’t run infinitely by adding a condition which will callexit.