日志输出到文件

摘要:[root@node110 pexpect]# cat simple6-output-logfile.py #!/usr/bin/env pythonimport pexpectimport sysshell_cmd='ls -l'child = pexpect.spawn('/bin/bash',['-c',shell_cmd])fout = file('mylog.txt','w')child.logfile=fout#child.logfile=sys.stdoutchild.expect(pexpect.EOF)

 pexpect.EOF

摘要:[root@node110 pexpect]# cat simple4.py #!/usr/bin/env pythonimport pexpectchild = pexpect.spawn('/bin/bash -c "ls -l > logs.txt"')child.expect(pexpect.EOF) #匹配数据的最后,表示数据传输完成#!/usr/bin/env pythonimport pexpectshell_cmd='ls -l>logs1.txt'child = pexpect.spawn('/bin/bash',['-c',shell_cmd])child.expect(pexpect.EOF)

 远程打包文件并备份到本地

摘要:[root@node110 pexpect]# cat simple3.py import pexpectimport sysip="192.168.198.121"user="root"passwd="123456"target_file="/etc/passwd"child = pexpect.spawn('/usr/bin/ssh', [user+'@'+ip])fout = file('mylog.txt','w')child.logfile = fouttry:    child.expect('(?i)password')    child.sendl

 ftp_login.py

摘要:[root@node110 pexpect]# cat ftp_login.py from __future__ import unicode_literalsimport pexpectimport syschild = pexpect.spawnu('ftp ftp.openbsd.org')child.expect('(?i)name .*: ')child.sendline('anonymous')child.expect('(?i)password')child.sendline('pexpect@sourceforge.net')child.expect('ftp> ')child.sendline('bin')child.expect('ftp> ')ch

 pexpect_spawn_auto_ssh_login.py

摘要:[root@node110 pexpect]# cat pexpect_spawn_auto_ssh_login.py #!/usr/bin/env pythonimport pexpectchild = pexpect.spawn('scp /usr/local/src/python/pexpect/pexpect-3.0.tar.gz  root@192.168.198.121:/root/')#child.expect("root@192.168.198.121's password:")child.expect("password:")child.sendline('123456')

 Docker数据管理

摘要:数据卷: 在Docker容器内将里面的数据直接写到硬盘上-v /data[root@node121 data]# docker run -it --namevolume-test1 -h centos -v /docker/data centos        -i :让终端保持打开的状态        -t:启动一个tty        -h:指定主机名   &nb

 Docker FAQ FATA[0000] Error starting daemon: Error initializing network controller: Error creating d

摘要:FATA[0000] Error starting daemon: Error initializingnetwork controller: Error creating default "bridge" network: packagenot installed  解决方法: docker -d –bip=172.17.42.1/16 指定一个docker网段就可以成功启动了   网上有好多类似的解决方法,不过好麻烦,这里主要说下最方便的解决方法 先su到root 找一下doc

 Docker FAQ FATA[0000] Error mounting devices cgroup: mountpoint for devices not found

摘要:FATA[0000] Error mounting devices cgroup: mountpoint fordevices not found这个错误为cgroup在宿主机上没有挂载。我们编辑挂载上去            vi /etc/fstab#在结尾添加none       /sys/fs/cgroup        cgroup    &

 Docker --help

摘要:[root@node121 ~]# docker --helpUsage: docker [OPTIONS] COMMAND [arg...] A self-sufficient runtime for linux containers. Options:  --api-cors-header=                  Set CORS headers in the remote API  -b,--bridge=   &nb

 在宿主机查看docket容器的IP

摘要: 在宿主机查看docket容器的IP:docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER_ID[root@node121 ~]# docker inspect --format='{{.NetworkSettings.IPAddress}}' 462442d61745 172.17.0.2
分页:« 1 2 3 4 5 6 7 8 »
Powered by AKCMS