rabin 7 years ago
commit
49006e7e31
1 changed files with 25 additions and 0 deletions
  1. 25 0
      test.py

+ 25 - 0
test.py

@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+	demeter core
+	name:demeter.py
+	author:rabin
+"""
+
+import pexpect
+ 
+if __name__ == '__main__':
+    user = 'root'
+    ip = '192.168.33.10'
+    port = '3309'
+    password = '123456'
+
+    child = pexpect.spawn('mysql -u%s -h%s -P%s -p' % (user, ip, port))
+    child.expect ('password:')
+    child.sendline (password)
+ 
+    child.expect('>')
+    child.sendline('show databases;')
+    #print child.before   # Print the result of the ls command.
+    child.sendline('exit')
+    child.interact()     # Give control of the child to the user.