Hi Andrew,
I'm using ssh2shell in my project to execute several commands and bash scripts on a remote server, and ofcourse get each command response and use it in some analysis later.
What I`m facing is that, when executing the bash script on the remote server, I'm getting the response containing the script itself and the out put as well. I will post here part of the code to give more details about what is going on:
CODE HERE - ALL THE BELOW:
let host = { server: { host: config.host, port: config.port, userName: config.username, password: config.password, privateKey: config.privateKey, tryKeyboard: true, algorithms: algorithmObj, }, asciiFilter:"[^\r\n\x20-\x7e]", disableASCIIFilter:true, disableColorFilter:true, closedMessage:"Closed", debug:hostdebug, standardPrompt:">$%#", commands: [ bash -s ${fs.readFileSync('./script1.sh', 'utf-8')}`,
'Hello World',
'ls l'
],
idleTimeOut:30000,
showBanner: true,
window: true,
onCommandComplete: async function( command, response,sshObj,stream) {
const result.output=response;
},
};
return new Promise(( resolve, reject ) => {
let SSH = new SSH2Shell(host),
callback = function(sessionText){
resolve(commandResponses);
}
ssh2shellInstances.push(SSH);
SSH.on('error', reject);
SSH.connect(callback);
SSH.on ('emitCloseStream', function onClose(){
this.emit('closeStream');
});
SSH.on ('commandProcessing', function onCommandProcessing( command, response, sshObj, stream ) {
this.on('closeStream',()=>{
stream.close();
ssh2shellInstances.pop();
})
});`
Plz support on a way to get the response of bash script as its output only without the script itself after execution on the remote host.
Hi Andrew,
I'm using ssh2shell in my project to execute several commands and bash scripts on a remote server, and ofcourse get each command response and use it in some analysis later.
What I`m facing is that, when executing the bash script on the remote server, I'm getting the response containing the script itself and the out put as well. I will post here part of the code to give more details about what is going on:
CODE HERE - ALL THE BELOW:
let host = { server: { host: config.host, port: config.port, userName: config.username, password: config.password, privateKey: config.privateKey, tryKeyboard: true, algorithms: algorithmObj, }, asciiFilter:"[^\r\n\x20-\x7e]", disableASCIIFilter:true, disableColorFilter:true, closedMessage:"Closed", debug:hostdebug, standardPrompt:">$%#", commands: [bash -s ${fs.readFileSync('./script1.sh', 'utf-8')}`,'Hello World',
'ls l'
],
idleTimeOut:30000,
showBanner: true,
window: true,
return new Promise(( resolve, reject ) => {
Plz support on a way to get the response of bash script as its output only without the script itself after execution on the remote host.