I have a path variable and wanted to check given path is executable file or not
boolean isExecutable = false
def process = ("file " + "/abc/xyx/abcd.sh").execute()
log.info("printing the output: ")
process.text.eachLine {
if (it.contains("executable")) {
isExecutable = true
}
}
if(isExecutable){
println "file is executable"
}
With the above code I am able to find out whether that file is executable or not. But just wanted to know that is there any other alternatives to find out the file type in groovy