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

Handle a confirm prompt with oxidized-script #32

Open
sebisme opened this issue Apr 2, 2019 · 1 comment
Open

Handle a confirm prompt with oxidized-script #32

sebisme opened this issue Apr 2, 2019 · 1 comment
Labels

Comments

@sebisme
Copy link

sebisme commented Apr 2, 2019

Hello,

I must change a local user password on a large quantity of switches (cisco ios) that are all backed up in oxidized. I have tried to create a ruby script to do so, but as i change the config, I would like to save the current config with
copy run start
But I don't know how to handle the "confirm" prompt.
The confirm prompt is Destination filename [startup-config]? and waits for 'y' or 'n', of course.
How to change the expected output for that very command only ?

Here is the main action inside a loop on each switch in the script :

#!/usr/bin/env ruby

require 'oxidized/script'

Oxidized::Config.load
Oxidized.setup_logger

Oxidized::Script.new(:host=>'10.102.160.1') do |oxs|
  puts oxs.cmd 'conf t'
  puts oxs.cmd 'username mylocaluser privilege 7 secret mylocalpwd'
  puts oxs.cmd 'exit'
  puts oxs.cmd 'copy run start' # Here I should change the expected answer
  puts oxs.cmd ''
end
@laf
Copy link
Contributor

laf commented Apr 2, 2019

Just change copy run start for write mem?

Alternatively have you tried to add a newline at the end of copy run start\n

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

No branches or pull requests

2 participants