Centos小脚本(sftp)
sftp用户创建,改变属组,家目录
#!/bin/python
import os,sys
class sftp_user(object):
def __init__(self,user,passwd):
self.user = user
self.passwd = passwd
# 改变用户的属组
def user_mod(self):
for i in self.user:
data = os.popen("usermod -g sftp %s"%i).read()
print(data)
#增加账户及设置密码
def user_add(self):
connect = 0
for i in self.user:
output1 = os.popen("useradd %s"%i).read()
print(output1)
#output = os.popen("echo '%s:%s'|chpasswd"%(i,j)).read()
output2 = os.popen("echo '%s' |passwd --stdin %s"%(self.passwd[connect],i)).read()
connect += 1
print(output2) #删除用户及家目录
def user_del(self):
for i in self.user:
output = os.popen("userdel %s"%i).read()
os.popen("rm -rf /home/%s"%i)
print(output)
def fill_create(self):
pass
#改变用户家目录及改变权限
def fill_chown(self):
for i in self.user:
os.popen("usermod -d /mnt/ftp/chinaflux/tongliangshuju-2-jieguo/%s %s"%(i,i))
os.popen("chown %s:sftp -R /mnt/ftp/chinaflux/tongliangshuju-2-jieguo/%s"%(i,i))
os.popen("chmod 755 /mnt/ftp/chinaflux/tongliangshuju-2-jieguo/%s"%i) user = ["arou","ailaoshan","damao""daxinganling","danzhou"]
passwd = ["arou","ailaoshan","damao""daxinganling","danzhou"]
abc = sftp_user(user,passwd)
abc.user_add()
#abc.user_del()
Centos小脚本(sftp)的更多相关文章
- centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课
centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 ...
- centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课
centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件.目录属性 shell数组简单用法 $( ) 和$ ...
- centos 查看脚本
centos 查看脚本 #!/bin/bash date >>info.txt echo "本机centos版本为" >>info.txt cat /etc ...
- 第一个Mac shell 小脚本
大多数程序员都喜欢偷懒的,我也不例外.相信好多Android开发的coder 在网络http请求方面,会浪费很多时间在接口调试这里..有时候,自己写了一个小测试,行还好,不行的话,还要跟写后台的哥们一 ...
- 写了一个常规性生成merge 的小脚本
现在使用数据库来写存储过程,动不动参数就会用到xml ,当然罗,优势也很明显,参数相对固定,而且灵活,如果要修改或者什么的,中间接口层也不需要做变化,只需要修改封装的存储过程以及程序传参就ok了. 随 ...
- 周末娱乐一下--------恶搞windows小脚本
下面这是个循环DOS命令,使用了C中的goto语句 echo命令式输出命令 set命令是设置命令 var是变量,初始为0 :continue是一个用于goto的标示. %var%输出变量名,%var% ...
- 用Python实现一个爬取XX大学电费通知的小脚本
内容简要 1分析网站 2简单爬取 3进阶自定义爬取 4保存进数据库 学校基础设施太差,宿舍电量过低提醒虽然贴在楼下,但是作为低头一族,经常忘记看提醒导致宿舍酣战时突然黑屏,为了避免这种尴尬的场景以及强 ...
- 分享一个刷网页PV的python小脚本
下面分享一个小脚本,用来刷网页PV. [root@huanqiu ~]# cat www.py #!/usr/bin/python# coding: UTF-8import webbrowser as ...
- 自动FTP的小脚本
自动FTP的小脚本 使用以下脚本,可以实现自动FTP,将你需要的文件传送到需要的地方,或者将需要的文件从某个地方抓取下来. cd /PATH_YOU_WANT_TO_UPLOAD(DOWNLOAD) ...
随机推荐
- selenium 自动化工具
问题 今天在使用selenium+PhantomJS动态抓取网页时,出现如下报错信息: UserWarning: Selenium support for PhantomJS has been dep ...
- 关于web上文章移植伴随的样式问题
好多朋友疑问,关于网页上的html文章在不同编辑器和页面之间复制黏贴时伴随的样式(如css)是否也一起被复制.这里统一回答下: 很多人遇见这种情况:网页上看到一篇内容充实主题明确,更重要的是样式精美的 ...
- Spring 入门之-dao使用jdbcTemplate(注入过程)
技巧:在为把dataSourc连接池注入到jdbcTemplate里面时,学到一招:按住CTRL 不松,点击相关类名,可以自动跳转或打开. 说明:主要过程, 1.创建UserDao和UserServi ...
- Branching / Tagging
Branching / Tagging One of the features of version control systems is the ability to isolate changes ...
- centos7 笔记本盒盖不睡眠
cd /etc/systemd vi logind.conf 动作包括:HandlePowerKey:按下电源键后的动作HandleSleepKey:按下挂起键后的动作HandleHibernateK ...
- Android记住password后自己主动登录
/** * * @author alex * @version 2014-7-31下午5:25:45 * */ public class LoginActivity extends Act ...
- poj 3670(LIS)
// File Name: 3670.cpp // Author: Missa_Chen // Created Time: 2013年07月08日 星期一 21时15分34秒 #include < ...
- NOIP2011提高组(选择客栈)
题目链接:http://codevs.cn/problem/1135/ 题目大意:中文题...就不解释了 题目思路:看了其他巨巨的blog写的,dp思路 #include <iostream&g ...
- 【BZOJ3930】[CQOI2015]选数 莫比乌斯反演
[BZOJ3930][CQOI2015]选数 Description 我们知道,从区间[L,H](L和H为整数)中选取N个整数,总共有(H-L+1)^N种方案.小z很好奇这样选出的数的最大公约数的规律 ...
- python清除字符串中间空格的方法
1.使用字符串函数replace >>> a = 'hello world' >>> a.replace(' ', '') 'helloworld' 看上这种方法真 ...