bash$ cat ~/bin/sp1rep #!/usr/local/bin/python import pexpect import sys child = pexpect.spawn('ssh -l test 10.3.18.37'); child.logfile = sys.stdout child.expect('assword:'); child.sendline('click1'); child.sendline(''); child.expect('#'); child.sendline('setenv TERM vt100'); child.expect('#'); child.sendline('su'); child.expect('assword:'); child.sendline('click1'); child.sendline(''); child.expect('#'); child.sendline('rep'); #child.sendline('exit'); #child.sendline('exit'); child.expect(pexpect.EOF); #print child.before; bash$ cat ~/bin/sp1upgrade #!/usr/local/bin/python import pexpect import sys import commands (status, output) = commands.getstatusoutput('buildname'); print output; if status != 0: exit(-1); build = output.split()[2]; child = pexpect.spawn('ssh -l test 10.3.18.37'); child.logfile = sys.stdout child.expect('assword:'); child.sendline('click1'); child.sendline(''); child.expect('#'); child.sendline('su'); child.expect('assword:'); child.sendline('click1'); child.sendline(''); child.expect('#'); child.sendline('su array'); child.expect('>'); child.sendline('enable'); child.expect('nable password:'); child.sendline(''); child.expect('#'); child.sendline('admin reset config'); child.expect('#'); child.sendline('co t'); child.expect('/(config/)#'); child.sendline('system update ' + build); child.expect('to confirm upgrade :'); child.sendline('YES'); child.expect(pexpect.EOF, timeout=None); Install pexpect and easy_install, run as root: fetch http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py easy_install pexpect