Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending y/n response not working after second time #232

Open
rodware10 opened this issue Apr 24, 2023 · 0 comments
Open

Sending y/n response not working after second time #232

rodware10 opened this issue Apr 24, 2023 · 0 comments

Comments

@rodware10
Copy link

Hello I have the following code to reboot a device

connection.on('connect', async function () {
await connection.send('', async function (err, res) {
if (err) return err

    console.log('resp after cmd 1:', res.trim())
    await connection.send('reboot', async function (err, res) {
      if (err) return err

      if (res.indexOf('Save config to flash ') > -1) {
        console.log('resp after cmd 2:', res)
        await connection.send('n', async function (err, res) {
          if (err) return err

          console.log('resp uptime cmd 3:', res)
          await connection.send('y', async function (err, res) {
            if (err) return err

            console.log('resp uptime cmd 4:', res)
          })
        })
      } else {
        await connection.send('y', async function (err, res) {
          if (err) return err

          console.log('resp uptime cmd 4:', res)
        })
      }
    })
  })
});

and these are the outputs I'm getting

10055#
resp after cmd 2: reboot
Save config to flash ROM y/n

resp uptime cmd 3: n
Confirm reboot unit y/n
10055#
resp uptime cmd 4: y
?Unrecognised input
10055#

For some reason after the Confirm reboot unit y/n the process stops and after sending the "y" as response to confirm reboot it is taken as a new command so it returns Unrecognised input.

Thanks for you help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant