Help in using "lsof" command
596581Jun 6 2008 — edited Jun 9 2008Hi All,
I want to list out all the files which are in open state(in particular which are being copied to a particular source) in LINUX environment programatically. For this i am using "lsof (Lost of files)" command and running this in the java class by using "exec" command of Runtime class as shown below
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(/usr/sbin/lsof /home/filename.txt);
where /usr/sbin/lsof is the command and /home/filename.txt is the absolute path of the file whose state has to be known.
This command when executed as unix command is giving the expected result i.e listing the file if it in open state. Also the same command when used in a simple java class, gave the expected result. This class has been compiled and execute on LINUX machine.
But the same code when used in the application which has compiled on Windows machine and ported the class files as jar file to LLINUX machine not listing the files in open state.
Can anyone give me solution why this is happening? Please help me as early as possible.
Thanks