команда запуска без shell канала а через exec

v++
This commit is contained in:
2024-12-01 01:07:23 +03:00
parent b76aa24ae4
commit 216b595450
4 changed files with 101 additions and 12 deletions

View File

@@ -413,6 +413,7 @@ public class UserConnection {
}
}
//-----
/*
public void ShellConnect() throws Exception {
shellChannel = (ChannelShell) session.openChannel("shell");
in = new PipedInputStream();
@@ -425,10 +426,6 @@ public class UserConnection {
shellChannel.connect();
//-
fromServer = new InputStreamReader(pout);
/*
ShellParser.setUserName(user.login);
ShellParser.ReadInvitation(fromServer); //прочитать первое приглашение от машины.
*/
}
public void ShellDisconnect() throws Exception {
if (in != null) {
@@ -476,6 +473,8 @@ public class UserConnection {
shellChannel = null;
System.gc();
}
*/
public void waitForFileCreation(RemoteFile file) throws Exception {
while (!Exists(file)) {
System.out.println(file.full_name + " NOT FOUND");
@@ -507,6 +506,16 @@ public class UserConnection {
RemoteFile outFile = new RemoteFile(directory, outFileName);
if (Exists(outFile))
sftpChannel.rm(outFile.full_name);
//--
System.out.println("nohup " + start_command + " &\r\n");
execChannel = (ChannelExec) session.openChannel("exec");
execChannel.setErrStream(System.err);
execChannel.setCommand("nohup " + start_command + " &\r\n");
execChannel.connect();
execChannel.disconnect();
System.out.println("done");
//--
/*
System.out.println("connecting shell");
ShellConnect();
System.out.println("done");
@@ -521,6 +530,7 @@ public class UserConnection {
ShellDisconnect();
System.out.println("done");
// return readFromFile(outFile).replace("\n", "").replace("\r", "");
*/
}
//-- проверка существования рабочего пространства.
public void CheckUserInitialization(String email) throws Exception {