Eu tenho um problema ao tentar executar um comando com params via Java Runtime

0

Estou trabalhando em um aplicativo de desktop Java para gerenciar o iptables e quero executar comandos do iptables via Java. É isso que estou fazendo:

eu executo do terminal gksu "iptables -L" e funcionou mas quando tento executá-lo a partir do Java runtime (exec. ("gksu \" iptables -L \ "")) Eu continuo recebendo esta saída:

GKsu versão 2.0.2

Uso: gksu [-u] [opções]

- debug, -d

Print information on the screen that might be

useful for diagnosing and/or solving problems.

- user, -u

Call <command> as the specified user.

- disable-grab, -g

Disable the "locking" of the keyboard, mouse,

and focus done by the program when asking for

password.

- prompt, -P

Ask the user if they want to have their keyboard

and mouse grabbed before doing so.

- preserve-env, -k

Preserve the current environments, does not set $HOME

nor $PATH, for example.

- login, -l

Make this a login shell. Beware this may cause

problems with the Xauthority magic. Run xhost

to allow the target user to open windows on your

display!

- descrição, -D

Provide a descriptive name for the command to

be used in the default message, making it nicer.

You can also provide the absolute path for a

.desktop file. The Name key for will be used in

this case.

- message, -m

Replace the standard message shown to ask for

password for the argument passed to the option.

Only use this if --description does not suffice.

- print-pass, -p

Ask gksu to print the password to stdout, just

like ssh-askpass. Useful to use in scripts with

programs that accept receiving the password on

stdin.

- sudo-mode, -S

Make GKSu use sudo instead of su, as if it had been

run as "gksudo".

- su-mode, -w

Make GKSu use su, instead of using libgksu's

default.

Espero que alguém possa me ajudar: D plox: P

    
por Luis Javier Pena Urena 02.06.2011 / 17:44

1 resposta

3

Você não está fazendo certo. Faça um array de string. O primeiro elemento será o nome do comando e os seguintes elementos serão argumentos. link

    
por nickguletskii 02.06.2011 / 17:49