如何用 scp命令创建文件夹
2个回答
展开全部
调用的是下面的方法
public static int runSSH(String host, String username, String password,
String cmd) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("running SSH cmd [" + cmd + "]");
}
Connection conn = getOpenedConnection(host, username, password);
Session sess = conn.openSession();
sess.execCommand(cmd);
InputStream stdout = new StreamGobbler(sess.getStdout());
BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
while (true) {
// attention: do not comment this block, or you will hit
// NullPointerException
// when you are trying to read exit status
String line = br.readLine();
if (line == null)
break;
if (logger.isDebugEnabled()) {
logger.debug(line);
}
}
sess.close();
c氦俯份谎莓荷逢捅抚拉onn.close();
return sess.getExitStatus().intValue();
}
public static int runSSH(String host, String username, String password,
String cmd) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("running SSH cmd [" + cmd + "]");
}
Connection conn = getOpenedConnection(host, username, password);
Session sess = conn.openSession();
sess.execCommand(cmd);
InputStream stdout = new StreamGobbler(sess.getStdout());
BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
while (true) {
// attention: do not comment this block, or you will hit
// NullPointerException
// when you are trying to read exit status
String line = br.readLine();
if (line == null)
break;
if (logger.isDebugEnabled()) {
logger.debug(line);
}
}
sess.close();
c氦俯份谎莓荷逢捅抚拉onn.close();
return sess.getExitStatus().intValue();
}
展开全部
调用的是下面的方法
public static int runSSH(String host, String username, String password,
String cmd) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("running SSH cmd [" + cmd + "]");
}
Connection conn = getOpenedConnection(host, username, password);
Session sess = conn.openSession();
sess.execCommand(cmd);
InputStream stdout = new StreamGobbler(sess.getStdout());
BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
while (true) {
// attention: do not comment this block, or you will hit
// NullPointerException
// when you are trying to read exit status
String line = br.readLine();
if (line == null)
break;
if (logger.isDebugEnabled()) {
logger.debug(line);
}
}
sess.close();
conn.close();
return sess.getExitStatus().intValue();
}
public static int runSSH(String host, String username, String password,
String cmd) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("running SSH cmd [" + cmd + "]");
}
Connection conn = getOpenedConnection(host, username, password);
Session sess = conn.openSession();
sess.execCommand(cmd);
InputStream stdout = new StreamGobbler(sess.getStdout());
BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
while (true) {
// attention: do not comment this block, or you will hit
// NullPointerException
// when you are trying to read exit status
String line = br.readLine();
if (line == null)
break;
if (logger.isDebugEnabled()) {
logger.debug(line);
}
}
sess.close();
conn.close();
return sess.getExitStatus().intValue();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询