Must be connected to a terminal exception in Java while running the command: screen -s

138 Views Asked by At

I have an implementation in Java that opens channel's connection and sends a remote commands to there. The problem I'm having, is that the following command doesn't work when sending it through Java:

screen -S 'screen name'

The exception I get is: Must be connected to a terminal. When I go to the secureCRT to run my remote command manually, it works and creates a new screen. This code block is standard connection and sending command, and this is where I get the exception:

            channel = connection.openChannel("exec");
            channel.setCommand(command);
            channel.setInputStream(null);
            InputStream inputStream = channel.getInputStream();
            channel.connect();
            commandOutput.append(IOUtils.readFully(inputStream)); 
            channel.disconnect();
            

            
0

There are 0 best solutions below