Call to sudo

Is possible to call to sudo before of run a ruby statement (for that
can be run that statement)?

Hi Kless.

I think you're talking about passing commands through the 'system' command.
How about something like this:

  system("sudo rm -rf /path/to/directory")

James

···

On Sat, Oct 18, 2008 at 10:39 AM, Kless <jonas.esp@googlemail.com> wrote:

Is possible to call to sudo before of run a ruby statement (for that
can be run that statement)?

So, is not possible anything as: ?

···

On 18 oct, 15:47, James Herdman <james.herd...@gmail.com> wrote:

Hi Kless.

I think you're talking about passing commands through the 'system' command.
How about something like this:

system("sudo rm -rf /path/to/directory")

---------------
system("sudo")
FileUtils.mkdir_p(dir_root) unless File.exist?(dir_root)
---------------

Kless wrote:

So, is not possible anything as: ?

system("sudo")
FileUtils.mkdir_p(dir_root) unless File.exist?(dir_root)

No. The system command runs sudo in a shell - a separate executing binary
image - and then throws away its context and returns. The commands then run
without super-user support.

Now what's the outer problem that makes you need sudo?

···

--
  Phlip

Now what's the outer problem that makes you need sudo?

Create the '/usr/local/share/java' directory if it isn't already
created.

It was more easy to make:

···

-------------
dir_root = /usr/local/share/java
FileUtils.mkdir_p(dir_root) unless File.exist?(dir_root)
-------------

but I'm supposed that in this case I'll have to make:
-------------
if not File.exist?(dir_root)
   system("sudo mkdir -p #{dir_root}")
end
-------------

Kless wrote:

  system("sudo mkdir -p #{dir_root}")

First, puts a string that advises the user why they might need to enter
their password.

But shouldn't you be using a high-level installer for Java itself?

No. I've to install anything JAR files in that directory.

···

On 18 oct, 16:50, "Phlip" <phlip2...@gmail.com> wrote:

Kless wrote:
> system("sudo mkdir -p #{dir_root}")

First, puts a string that advises the user why they might need to enter
their password.

But shouldn't you be using a high-level installer for Java itself?