第一种:#!/usr/bin/env pythonimport osip=os.popen("ifconfig eth0 | awk -F [:' ']+ 'NR==2{print $4}'")print ip.readline()第二种:>>> os.system("ifconfig eth0 | awk
注:先检查服务器是否安装了expect软件包#!/usr/bin/expect -fset timeout 30set user rootset password $$$$$$$$set remote_dir /mnt/sunjcset ip 162.16.203.38set local_dir /mntset log_file_dir /opt/spawn rsync -avz $user@$i
#!/usr/bin/env python# -*- coding: utf8 -*-import sys,os,timedb_user = 'postgres'db_pwd = 'postgres'db_port = '5432'db_name = 'CCIC2'backup_path = '/home/sunjc/back
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号