I am trying to use netmiko to automate my backups of Aruba wireless controllers. The challenge is when I initiate the backup it does not return a trailing prompt but instead prompts for password for ftp. I have attempted to use the expect string to handle this but not sure if I am using it incorrectly.
Python 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
from netmiko import ConnectHandler
wlc01 = {
... 'device_type': 'aruba_os',
... 'ip': '172.16.9.15',
... 'username': 'admin',
... 'password':'password',
... }
net_connect = ConnectHandler(**wlc01)
net_connect.send_command('backup flash', delay_factor=2)
'Please wait while we tar relevant files from flash...\nPlease wait while we compress the tar file...\nFile flashbackup.tar.gz created successfully on flash.\nPlease copy it out of the switch and delete it when done.\n'
cmd = 'copy flash: flashbackup.tar.gz ftp: 172.16.1.10 ftpuser /backups flashbackup.tar.gz'
pwd = 'password'
net_connect.send_command(cmd, expect_string=r':')
'Password:'
net_connect.send_command(pwd)
" ^\n% Invalid input detected at '^' marker.\n"
I am trying to use netmiko to automate my backups of Aruba wireless controllers. The challenge is when I initiate the backup it does not return a trailing prompt but instead prompts for password for ftp. I have attempted to use the expect string to handle this but not sure if I am using it incorrectly.
My code is below:
from netmiko import ConnectHandler
wlc01 = { 'device_type': 'aruba_os', 'ip': '172.16.9.15', 'username': 'admin', 'password':'password', }
net_connect = ConnectHandler(**wlc01)
net_connect.send_command('backup flash', delay_factor=2)
cmd = 'copy flash: flashbackup.tar.gz ftp: 172.16.1.10 ftpuser /backups flashbackup.tar.gz' pwd = 'password' net_connect.send_command(cmd, expect_string=r':') net_connect.send_command(pwd)
net_connect.disconnect()
The output I get when running the code is here:
Python 3.6.6 (default, Sep 12 2018, 18:26:19) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information.
Any guidance is appreciated.