Results 1 to 2 of 2
  1. #1
    emanuel is offline Member
    Join Date
    Sep 2014
    Posts
    7
    Rep Power
    0

    Default unable to run tshark command in java on ubuntu

    Hello,

    I am trying to run tshark command using runtime environment in java on ubuntu . My code is as follows :-


    try {
    String destip = map1.get((String) innObj.get("value"));
    Runtime run = Runtime.getRuntime();
    String tshk = "/usr/bin/tshark -r /home/pratibha/Desktop/vox.pcap -Y \"ip.dst == "
    + destip
    + " && http\" -T fields -e tcp.port -e col.Info";
    Process pr = run.exec(tshk);

    int exitcode = pr.waitFor();
    System.out.println(exitcode);
    BufferedReader buf = new BufferedReader(
    new InputStreamReader(pr.getInputStream()));

    String line = "";
    while ((line = buf.readLine()) != null) {
    System.out.println(line);
    }

    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }


    map1 is hashmap which contains the destination ip adress
    When i run the above code the exit code for process (pr) is 1 and hence the tshark command is not executing properly.
    Please help

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

Similar Threads

  1. Replies: 2
    Last Post: 07-24-2014, 10:29 AM
  2. Replies: 4
    Last Post: 04-06-2012, 09:30 AM
  3. Java TTS on Ubuntu with Festival
    By Desh Banks in forum Advanced Java
    Replies: 2
    Last Post: 01-06-2011, 01:09 AM
  4. Replies: 2
    Last Post: 01-09-2010, 07:05 AM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 01:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •