Skip to content

Instantly share code, notes, and snippets.

View jjam3774's full-sized avatar

Jeffrey James jjam3774

View GitHub Profile
@koba-ninkigumi
koba-ninkigumi / pexpect_sample.py
Created April 11, 2012 15:37
pexpectのサンプル
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from pexpect import *
log = file('mylog.txt','w')
c = spawn('/bin/bash')
c.expect_exact('$')
@chzyer
chzyer / python-pexpect.md
Created January 11, 2013 06:11
python命令行预处理实例[ssh远程连接]
import pexpect
ssh = pexpect.spawn('ssh localhost') #建立新线程,执行"通过ssh连接本地"
ssh.expect('.*password:') #正则匹配输入密码提示,匹配才继续执行
ssh.sendline("123456") #输入密码
ssh.interact() #执行
@cnsoft
cnsoft / Pexpect_demo2.py
Created May 17, 2013 03:56
I collect this examples. maybe you will need it soon.
#!/usr/bin/python
#
#Notice:Please close domain lookup on your router or switch.
__author__="ring0"
__date__ ="$2011-6-5 16:00:00$"
__version__ ="0.3"
import sys
try:
@rkrishnasanka
rkrishnasanka / pxsshCommand.py
Last active May 31, 2022 07:18
uses pexpect to automate ssh login
import pxssh
def send_command(s, cmd):
s.sendline(cmd)
s.prompt()
print s.before
def connect(user, host, password):
try:
s = pxssh.pxssh()
@tsu-nera
tsu-nera / tc_mkdir_expect.rb
Created July 15, 2013 07:40
Vagrant & sahara & minitest で エンドツーエンドを実施するサンプルテスト
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'pty'
require 'expect'
require 'timeout'
# expect で読み込んだ内容を標準出力に出力するおまじない
$expect_verbose=true
class MkdirExpect