0

I'm working on a Java desktop aplication to manage iptables and i want to execute iptables commands via Java, this is what i am doing:

i execute from terminal gksu "iptables -L" and it worked but when i try to execute it from Java runtime ( exec.("gksu \"iptables -L\" ") ) i keep getting this output:

GKsu version 2.0.2

Usage: gksu [-u ] [options]

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

--description , -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. 

I hope someone can help me :D plox :P

1 Answer 1

3

You are not doing it right. Make a string array. The first element will be the command name, and the following elements will be arguments. http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String[])

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.