mkdir -p not executing
I tried the solution in this issue to create multiple directories but could no make it work. #4
Is there an alternative method or a more detailed example of this use case?
Can you provide more information? Is there an error? Is there text on the stream.stderr stream? Does mkdir return a non-zero exit code?
There's no error code or an error event. Here's one of the variations I have tried
conn.on('ready', function () {
console.log('uploadSsh2 :: ready');
conn.exec('mkdir -p -f '+PATH.dirname(destPath),(err,channel)=>{
if(err){
conn.end();
callback(err);
}else{
console.log('ok');
channel.addListener('close',()=>{
console.log('close');
});
channel.addListener('end',()=>{
console.log('end');
})
channel.addListener('data',()=>{
console.log('data');
})
channel.addListener('readable',()=>{
console.log('readable');
})
channel.resume();
channel.stderr.resume();
console.log('resumed');
}
})
}).on('error',(err)=>{
conn.end();
callback(err);
}).connect(server);
You're ignoring any stderr data in that code (channel.stderr.resume()). Instead, try logging the output:
channel.stderr.pipe(process.stderr);
Also check the exit code passed to the 'exit' and 'close' event handlers.
I'm sorry I can't seem to make this work Can you please add the required lines to this code to create the path one/two/three
const Client = require('ssh2').Client;
var conn = new Client();
conn.on('ready', function () {
//mkdir....
}).on('error',(err)=>{
conn.end();
callback(err);
}).connect(server);
Did you check the stderr output? What exit status code (and/or signal) are you receiving in the 'exit' event handler?
No output in stderr and no exit code.
On Oct 24, 2017 11:51 PM, "Brian White" [email protected] wrote:
Did you check the stderr output? What exit status code (and/or signal) are you receiving in the 'exit' event handler?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mscdex/ssh2-streams/issues/84#issuecomment-339127041, or mute the thread https://github.com/notifications/unsubscribe-auth/ADCnaPfo0MLJsy9JZqbmE1Y50DdnARAMks5svk3KgaJpZM4PqTl- .
There has to be either an exit code or signal when the remote child process exits. Did you add something like this:
channel.on('exit', (code, signal) => {
console.log('code', code, 'signal', signal);
});
?
I have. Both are undefined This is on an sftp server if it make any difference
@pantos27 , did you get it working eventually? I have the same issue ... and no logs at all to help
@nosteine nope. Ended up using a different module https://www.npmjs.com/package/ftps