Hai, I am trying to capture packets using tshark from JAVA (OS: Ubuntu). From terminal i can run below command successfully. tshark -i any -o column.format:""source", "%s", "srcport", "%uS"" -f "port 80 or port 443" But from JAVA its throwing below message tshark: Invalid -o flag "column.format:""source"," But i can invoke commands like "tshark -i any" from java with out any issues. Is there any other thing i need to correct to get the exact output from JAVA. Please Help... asked 22 Jan '13, 22:59 Krishnaprasad |
2 Answers:
The problem why your Java application reports an invalid -o flag is because the version of the Runtime.exec method is responsible for splitting the supplied string into separate command line arguments. By default, this method uses the space, tab, newline, carriage-return and the form-feed characters. So as you can see, because there is a white space character between [column.format:\"\"source\",] [\"%s\",], this version of the exec method treats them as 2 distinct arguments. The solution will be to use the other version of the Runtime.exec method which takes the system command and arguments in as an array parameter. You can therefore manually split out the command line arguments and define them as separate strings in the array parameter as follows:
answered 24 Jan '13, 01:29 Jeff Moszuti |
That's a problem with the quotes. You need to escape them with \.
Regards answered 22 Jan '13, 23:20 Kurt Knochner ♦ edited 22 Jan '13, 23:56 @KurtThanks for your reply. I did the same here is the complete code, its not working. If i tried the same from terminal its working.. ====
(22 Jan '13, 23:45) Kurt Knochner ♦ Hai Kurt, No Luck I tried both i.e
AND this:
== Message
(23 Jan ‘13, 00:48) Krishnaprasad |
Excellent, It worked..... Thanks a ton :)
Its not related to tshark but if some one can help me with this issue that will be great...
http://stackoverflow.com/questions/14680942/how-to-pass-the-terminal-output-to-java-text-area-while-its-apperaing-in-termina