开发者

Executing Shell script from Java code

开发者 https://www.devze.com 2023-02-16 03:06 出处:网络
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...

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号