title: Runtime.getRuntime().exec JAVA method not working with tshark -o
body: <p>I am trying to capture packets using tshark from JAVA.[Pls find below]</p>
  
  <p>If i tried the command from terminal (Ubuntu) its working. But from JAVA its throwing error tshark:</p>
  
  <blockquote>
    <p>Invalid -o flag "column.format:""source","</p>
  </blockquote>
  
  <p>I tried following alternatives [error msg same]</p>
  
  <pre><code>String[] cmdArray = {"tshark -i any -o column.format:\"source, %s, srcport, %uS\" -f \"port 80 or port 443\""};
  </code></pre>
  
  <p>AND this:</p>
  
  <pre><code>String[] cmdArray = {"tshark -i any -o column.format:'source, %s, srcport, %uS' -f 'port 80 or port 443'"};
  
  
  //CommandExc.java
  
  import java.io.*;
  
  import java.util.*;
  
  
  public class CommandExc
  {
  public static void main (String args[])
   {
  
      //This worked Succcessfully
      //String[] cmdArray = {"tshark -D","sudo tshark -D"};
  
  String[] cmdArray = {"tshark -i any -o column.format:\"\"source\", \"%s\",\"srcport\", \"%uS\"\" -f \"port 80 or port 443\""};
  
      for (String cmd: cmdArray) 
      {
           System.out.println("Executing command : "+cmd);
          try
          {
              Process proc = Runtime.getRuntime().exec(cmd); 
              BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
              String str = in.readLine();
              while(str != null)
              {
                  System.out.println(str);
                  //  res += str + "\n";
                  str = in.readLine();
              }
              in.close();          
  
              BufferedReader in2 = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
              String str1 = in2.readLine();
              while(str1 != null)
              {
                  System.out.println("Inside getErrorStream "+str1);
                  //  res += str + "\n";
                  str1 = in2.readLine();
              }
              in2.close();
  
              proc.waitFor();
              System.out.println("Exit value is : "+proc.exitValue());
              proc.destroy();
          }
          catch(IOException | InterruptedException e)
          {
              System.out.println("Exception on CommandExc class :" + e.toString());
                              e.printStackTrace();
          }
      } //end of for
    }
  }
  </code></pre>