Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
how to return response to event the telnet-client nodejs

I need your help about how return the response to execute cmd on telnet-client, in this momment just have te response in the event 'ready' but don´t have return to principal funcion.

this is my code

const testTelnet = async (host, dns) => {

process.on('unhandledRejection', error => {
    console.log("**TELNET CONNECTION ERROR ***", error);

});

const params = {
    host: host,
    port: 23,
    shellPrompt: '#',
    negotiationMandatory: false,
    loginPrompt: dns + ' login:',
    username: user,
    password: password,
    failedLoginMatch: '/error en autenticacion/',
    timeout: 5000,
}

const res = connection.on('ready', prompt => {

    connection.exec(cmd, (err, response) => {
        console.log("pront", prompt);
        console.log(response)
        return response;  // **** NEED RETURN THIS RESPONSE
    })
})

console.log("resultado: ", res)

connection.on('timeout', () => {
    console.log('socket timeout!')
    connection.end()
})

connection.on('close', () => {
    console.log('connection closed')
})

connection.connect(params)

return response;

}

almost 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!