[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Call to sudo

Kless

10/18/2008 2:39:00 PM

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

James Herdman

10/18/2008 2:47:00 PM

0

[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

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)?
>
>

Kless

10/18/2008 3:14:00 PM

0

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

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

Phlip

10/18/2008 3:21:00 PM

0

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


Kless

10/18/2008 3:36:00 PM

0

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

Phlip

10/18/2008 3:51:00 PM

0

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?


Kless

10/18/2008 4:53:00 PM

0

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?

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