I need to run a shell script in linux from Java; but before running the script there should be minimum of 2GB space available in linux directory. Could you please tell me a better approach for this in Java?
Think before you speak as you might hurt or break someone's heart.
You can then check $DIRFREE. Note that the "quotes" are back-tick characters (usually on the keyboard left of the "1" key) and not apostrophe/single-quotes. And that the "cut" options have double dashes, not single ones. And finally, that there's exactly one space between the single quotes on the "tr" command.
This sets the number of free bytes on the drive containing /var/lib/mywork into the DIRFREE variable.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Dec 06, 2008
Thanks a lot for the command, it worked.
I tried to understand the command and came to know that this will also work
df -P /var/lib/mywork | tail -n 1 | tr -s ' ' ':' | cut -d : -f 4
And to have the output in human readable form, the command could be
df -P -h /var/lib/mywork | tail -n 1 | tr -s ' ' ':' | cut -d : -f 4
By looking at the man page for df, it is easy to see that the -P option specifies that the output of df should be in POSIX format - a format that should be the same on all *nix systems, whether you are on a SysV, AIX, HPUX, Linux, BSD, MacOS, FTX, ... system.
As you look at the man pages, you can then ask individual questions about different commands and/or the parameters they take if you are still confused.
Doing it this way will help you understand what is going on in far more detail, and you will then be able to customize it and/or build your own scripts to meet your own needs.