Executing Shell script from Java code
I have开发者_高级运维 the gui which have the button as "mount to server"....am having the ubuntu client and server system.....When I click the mount button ,it should mount to server folder... for example, one folder name "OUTPUT" is in the server..in client machine folder is "OUTPUT FILES"...through linux command i can mount the server "OUTPUT" folder from client folder "OUTPUT FILES".... But , in java when i press the mount button, it should mount the server "OUTPUT" folder..should i need any shellscript code?...how to do? and how to get the server system ip address?...can u plz anyone help me?
You can write a shell script to mount the server folder onto your client's filesystem. Once you have that working, you can just execute this shell script from Java code using Runtime class.
String IPAddress = "...";
String script= "/path/to/your/script.sh";
String[] cmd = {script, IPAddress};
Runtime rt = Runtime.getRuntime();
rt.exec(cmd);
精彩评论