11 Replies - 389 Views - Last Post: 07 October 2012 - 06:37 AM Rate Topic: -----

#1 theshowtekfan  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 147
  • Joined: 27-September 11

need help executing program in linux

Posted 06 October 2012 - 03:10 PM

hey guys im currently trying to make a litlle handy tool, u see i am a network administrator and my boss told me that he wanted me to monitor the network and block certain sites and ip for some game servers, so for the monitoring part we are going to redirect all traffic on the network to a server where we can monitor the traffic before sending it to the gateway...

for this we are going to use arpspoof in linux and i have finished a solution for the blocking of sites and servers, and what i am going to make is a GUI that makes it easier for me to handle and control these things and when i tried running arpspoof from java using a ProcessBuilder it does not work and i get no output ? O.o

it also does not enter the while loop :/ i can't really think of more to write atm, but if i can think of more i will update this thread

my code:
new Thread() {
	public void run() {
		try {
	        	System.out.println("running arpspoof...");
			Process prb =new ProcessBuilder("gksudo","arpspoof","i","wlan0",Gateway).start();
			InputStream is = prb.getInputStream();
		    InputStreamReader isr = new InputStreamReader(is);
		    BufferedReader br = new BufferedReader(isr);

		     String line;
	        while ((line = br.readLine()) != null) {
		    	System.out.println("Output: " + line);
		}
	  	} catch (IOException e) {
			e.printStackTrace();
		}
	}
}.start();



Is This A Good Question/Topic? 0
  • +

Replies To: need help executing program in linux

#2 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1405
  • View blog
  • Posts: 3,120
  • Joined: 05-April 11

Re: need help executing program in linux

Posted 06 October 2012 - 03:18 PM

Wouldn't it be easier to do at router level :)?
Was This Post Helpful? 0
  • +
  • -

#3 theshowtekfan  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 147
  • Joined: 27-September 11

Re: need help executing program in linux

Posted 06 October 2012 - 03:24 PM

yes i can see why you would think so :P the problem is that we do not have access to the router, all the workstations are linked to the one linux server which is linked to the router, its a pretty big company so they have this system(that i kinda think sucks) but that does not change anything :S so could u guys help me out with my code ?
Was This Post Helpful? 0
  • +
  • -

#4 Ytry  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 120
  • Joined: 25-July 12

Re: need help executing program in linux

Posted 06 October 2012 - 03:27 PM

Well, I don't see any immediate errors, only thing I can think of is that for some reason there is nothing for the buffered reader to read.
Was This Post Helpful? 0
  • +
  • -

#5 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1405
  • View blog
  • Posts: 3,120
  • Joined: 05-April 11

Re: need help executing program in linux

Posted 06 October 2012 - 03:31 PM

Sorry I don't know enough about linux to help you out with the code, but doesn't linux have some iptables where you can block ip addresses? I would be surprised if they didnt :P

Lets hope there are some linux gurus here
Was This Post Helpful? 0
  • +
  • -

#6 theshowtekfan  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 147
  • Joined: 27-September 11

Re: need help executing program in linux

Posted 06 October 2012 - 03:32 PM

View PostYtry, on 06 October 2012 - 03:27 PM, said:

Well, I don't see any immediate errors, only thing I can think of is that for some reason there is nothing for the buffered reader to read.

yea thats kinda obvious but if i run it from a shell it gives me tons of output :S
Was This Post Helpful? 0
  • +
  • -

#7 Ytry  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 120
  • Joined: 25-July 12

Re: need help executing program in linux

Posted 06 October 2012 - 03:40 PM

Is there a possibility that for some reasons the process builder is not getting any data to pass into InputStream? You said that when you run it from a shell you get tons of output, if that is the case then it I don't see how it could be a problem with your code. I assume there is some problem with the process builder.
Was This Post Helpful? 0
  • +
  • -

#8 theshowtekfan  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 147
  • Joined: 27-September 11

Re: need help executing program in linux

Posted 06 October 2012 - 03:44 PM

View PostYtry, on 06 October 2012 - 03:40 PM, said:

Is there a possibility that for some reasons the process builder is not getting any data to pass into InputStream? You said that when you run it from a shell you get tons of output, if that is the case then it I don't see how it could be a problem with your code. I assume there is some problem with the process builder.


hmm yea but what ? that code right there is the only code for that specific method :/
Was This Post Helpful? 0
  • +
  • -

#9 Ytry  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 120
  • Joined: 25-July 12

Re: need help executing program in linux

Posted 06 October 2012 - 03:51 PM

 Process prb =new ProcessBuilder("gksudo","arpspoof","i","wlan0",Gateway).start(); 

Shouldn't this be
 ProcessBuilder prb = new ProcessBuilder("gksudo","arpspoof","i","wlan0",Gateway).start(); 

Correct my if I am wrong though because I am still learning.
Was This Post Helpful? 0
  • +
  • -

#10 theshowtekfan  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 147
  • Joined: 27-September 11

Re: need help executing program in linux

Posted 06 October 2012 - 03:52 PM

View PostYtry, on 06 October 2012 - 03:51 PM, said:

 Process prb =new ProcessBuilder("gksudo","arpspoof","i","wlan0",Gateway).start(); 

Shouldn't this be
 ProcessBuilder prb = new ProcessBuilder("gksudo","arpspoof","i","wlan0",Gateway).start(); 

Correct my if I am wrong though because I am still learning.


its the samme code lol :P its just DIC fucking up the code format when pasting :S
Was This Post Helpful? 0
  • +
  • -

#11 Ytry  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 120
  • Joined: 25-July 12

Re: need help executing program in linux

Posted 06 October 2012 - 03:58 PM

Well, I really don't know all I can really tell you is that from what I can tell your code is fine, and it appears to be a problem with the process builder, I don't regularly use linux, so there is not much more I can determine. Sorry I couldn't be of more help.
Was This Post Helpful? 0
  • +
  • -

#12 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2773
  • View blog
  • Posts: 11,715
  • Joined: 20-September 08

Re: need help executing program in linux

Posted 07 October 2012 - 06:37 AM

http://technojeeves..../52-runtimeexec

Read the above thoroughly and follow any embedded links

This post has been edited by g00se: 07 October 2012 - 06:37 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1