Skip to content

New connection for each operation #2

Description

@Damienadv

Hi!
I found your ssh2-utils module and I think it's really good.

I'm wondering if there any way to use operations without opening and closing new connection for each operation?

Please, review my code part below:

//create autotest directory on server
ssh.mkdir(server, remoteTestDir, function (err, server, conn) {
    if (err) console.log(err);
    conn.end();
    console.log
});

//create LOGS directory on server
ssh.mkdir(server, remoteTestDir + 'logs/', function (err, server, conn) {
    if (err) console.log(err);
    conn.end();
});


//put 2pdmf file to server    
ssh.putFile(server, localUtilsDir + runDMFFileName, remoteTestDir + runDMFFileName, function (err, server, conn) {
    if (err) console.log(err);
    conn.end();
    console.log('put 2pdmf file to server');
});

I have to apply conn.end(); after each operation and I think that this is not the best solution.
Could you clarify if there is any other way to manage the code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions