Call to sudo

K

Kless

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

James Herdman

[Note: parts of this message were removed to make it a legal post.]

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
 
K

Kless

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")
So, is not possible anything as: ?
 
P

Phlip

Kless said:
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?
 
K

Kless

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:
 
P

Phlip

Kless said:
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?
 
K

Kless

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,041
Members
47,643
Latest member
ashutoshjha_1101

Latest Threads

Top