James Carlson wrote:
> I'd use:
>
> if [ -x /usr/sbin/svcadm ]; then
> # SMF is present
> else
> # SMF is not present
> fi
>
> In other words, test for the feature you actually want, rather than
> some unrelated artifact of the system, such as the kernel's version
> number.
I completely agree with the words above. Many well intentioned version
checks grow stale and cause problems later.
> (Not sure what the Java equivalent would be, but there ought to be
> one.)
This would get you started:
public class SvcCheck {
public static boolean check() {
java.io.File fi = new java.io.File ("/usr/sbin/svcadm");
return (fi.exists() && fi.canExecute());
}
public static void main(String[] args) {
if (check()) {
System.out.println("svcadm is available");
/* Go off and work with svcadm */
} else {
System.out.println("svcadm not found");
}
}
}
% javac SvcCheck.java
% uname -r
5.11
% java SvcCheck
svcadm is available
Over on a legacy system:
% uname -r
5.9
% java SvcCheck
svcadm not found
Hope this helps - Tim