Skip to content

Instantly share code, notes, and snippets.

@o0-o
Last active November 9, 2019 18:20
Show Gist options
  • Save o0-o/2f9877f38408eb6312b695c790ceab07 to your computer and use it in GitHub Desktop.
Save o0-o/2f9877f38408eb6312b695c790ceab07 to your computer and use it in GitHub Desktop.
[Update the Firmware on a Ubiquiti Edgeswitch vi SSH] Non-interactive installation of firmware on a Ubiqiuti EdgeSwitch #ubiquiti #edgemax #switch #expect
#!/usr/bin/env expect
set timeout 720
set host [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
set url [lindex $argv 3]
set ftp_pw [lindex $argv 4]
spawn bash -c "ssh -o StrictHostKeyChecking=no $user@$host"
expect "assword"
sleep 1
send "$password\r"
expect " >"
send "enable\r"
expect " #"
send "copy $url backup\r"
expect "assword"
sleep 1
send "$ftp_pw\r"
expect "(y/n)"
sleep 1
send "y"
expect " #"
send "boot system backup\r"
expect " #"
send "reload\r"
expect "(y/n)"
sleep 1
send "y\r"
send \033
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment