linux - What is JAVA exec()uting? -


i'm on linux , have java application (jar archive) using exec() it's stuff. need find out commands application exec()uting... tried strace , jstack without results. suppose app calling exec("ls"), can find ls command grepping output of above programs?

so question is: there simple way watch java application executing exec() ?

edit better situation overview:

suppose in java app have button onclick listener calls static function class.in function exec("ls"); called. when click button see in strace:

futex(0x7f14a6f799d0, futex_wait, 4968, nulldownload button clicked ! trying scp from... <unfinished ...>

trying scp from.. sout in button handler right before calling exec().

another edit: thank guys, i'm talking os point of view... suppose i'm sysadmin , downloaded jar. want know (from outside) jar doing - i'm interested in programs started exec()

so tried strace shows nothing calling command exec... maybe logging low level calls this...

then tried jstack -m can't find looking command exec. tried grepping string no luck.

ok, i'm going propose veeeeeeeeeery rudimentary way of doing things, might looking for.

as know, jar zip file comprised of java .class files. if need peek @ commands going executed, and if know class supposed execute them, can extract class files jar gzip , use strings on them commands.

for example, here's simple class think of uses exec():

import java.io.ioexception;  public class main {     public static void main(string[] args) {         try {             runtime.getruntime().exec("/bin/ls");         } catch (ioexception ignored) {}     } } 

if strings main.class sould this:

[...]$ strings main.class <init> code linenumbertable localvariabletable lmain; main ([ljava/lang/string;)v args [ljava/lang/string; stackmaptable sourcefile         main.java /bin/ls java/io/ioexception main java/lang/object java/lang/runtime getruntime ()ljava/lang/runtime; exec '(ljava/lang/string;)ljava/lang/process; 

as can see, /bin/ls can identified string. should work in cases, unless java program constructing commands in weird way, using char array create command strings during runtime obscure commands being executed (in case i'd highly suspicious of such program).

however, if want see commands executing in real time, i'm afraid you'll need resort monitoring utility, since commands short-lived appear on top , like.

edit: regarding strace: had @ java's native c code unix systems , seems uses execvpe() system call run commands launched runtime.exec():

    execvpe(argv[0], argv, envv); 

so, in theory, should able run strace -e execvpe <java command...> list every command executed (as every other call execvpe() -- you'll need filter bit more, that's true).


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -