Working with Unix server... My requirement is to read the name of the file that is there at /a/b/c/node01/d.ear
location on a Unix server and I have do the same through a java program. The problem is that the directory a
is a restricted directory and is accessible only to certain users. On the Unix side, I first issue a become
command like become a
, then supply the password and then using cd
command, I reach the d.ear
directory and then get to see the name of the file.
How do I do all of this via a Java program?
I don't mind if my Java program calls a shell script that accesses the restricted directory and then reach d.ear
and fetch the name of the file and returns the same to the java program. Do we have a way of doing this? Maybe issuing the become command inside the script which is called from the Java program and the password which is asked after become command is supplied as a parameter while calling the script???
Is this approach doable? I am very new to Unix commands and JSch library. Kindly provide the code or any other alternate solutions...
Thanks!!!