This doesn't work,
Runtime.getRuntime().exec("stat /*");
nor this;
Runtime.getRuntime().exec(new String[] {"stat", "/*"})
Is there any way around it ?
Thanks,
The asterisk is expanded by the shell (this is called globbing). So you actually want to execute the /bin/sh executable (most likely - substitute another shell here if required), and invoke stat /* from that. e.g. execute:
/bin/sh -c "stat /*"
from your Java process. -c specifies that /bin/sh executes whatever is in the string following the -c.
Alternatively you could perform the /* expansion yourself by finding all the files in the root directory in Java, and then pass those as args to stat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With