来自Java的Linux命令 [英] Linux commands from Java

查看:87
本文介绍了来自Java的Linux命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以用java执行linux命令?我正在尝试创建一个Web servlet,以允许ftp用户在没有ssh登录访问权限的情况下更改其密码。我想执行下一个命令:

  #adduser -s / sbin / nologin clientA -d / home / mainclient / clientA 
#passwd clientA
#cd / home / mainclient; chgrp -R mainclient clientA
#cd / home / mainclient / clientA; chmod 770。


解决方案

查看这个



<但是,做你正在谈论的是超出规范的方式,我不会推荐它。要使其工作,您将以root身份运行您的应用服务器,或使用其他一些机制为用户提供应用服务器作为执行这些特权命令的权限运行。一个小的搞砸了,你被拥有。


Is it possbile to execute linux commands with java? I am trying to create a web servlet to allow ftp users to change their passwords without ssh login access. I would like to execute the next commands:

# adduser -s /sbin/nologin clientA -d /home/mainclient/clientA
# passwd clientA
# cd /home/mainclient; chgrp -R mainclient clientA
# cd /home/mainclient/clientA; chmod 770 .

解决方案

Check out this.

However, doing what you are talking about is way outside spec, and I wouldnt reccommend it. To get it to work you are going to either run your app server as root, or use some other mechanism to give the user the app server is running as permission to execute these privileged commands. One small screw-up somewhere and you are "owned".

这篇关于来自Java的Linux命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆