I am trying to automate ssh connectivity using keepassdb and I am just starting out the script to interrogate the keypass kpcli shell. I want it to print out the result at the end.
# -*- coding: utf -*-
import os,sys
import pexpect
global str
db_kp='/media/sf_VM_shared/passwords.kdb'
pass_kp='KDBPASSWORD'
kp = pexpect.spawn('/usr/bin/kpcli')
kp.expect('>')
kp.sendline=('open /media/sf_VM_shared/passwords.kdb')
kp.expect=('Please provide the master password:')
kp.sendline=(pass_kp)
kp.expect('>')
kp.sendline=('cd General/Network/Firewalls/SSH/')
kp.expect=('kpcli:/General/Network/Firewalls/SSH>')
kp.sendline=("show -f 0")
print(kp.before)
I am getting the following when trying to run the file:
python3 ssh_firewall.py
Traceback (most recent call last):
File "ssh_firewall.py", line 12, in <module>
kp.expect('>')
TypeError: 'str' object is not callable