expect交互式创建账号密码
这个脚本是我在建立samba用户的时候用到的,一开始我是一步一步的操作,后来嫌麻烦了,就写了这个脚本,也学习了一下expect。
#!/usr/bin/expect
set user [lindex $argv 0]
set pass [lindex $argv 1]
spawn sed -i "s/123,/&$user,/g" /etc/samba/smb.conf 将新用户添加到smb配置文件
spawn useradd -s /bin/sh -d /home/$user $user 建立系统用户
expect "*#"
spawn passwd $user 创建密码
expect "*password:"
send "$pass\r"
expect "*password:"
send "$pass\r"
spawn smbpasswd -a $user 添加用户到sbm
expect "*password:"
send "$pass\r"
expect "*password:"
send "$pass\r"
interact
注释:
spawn: 后面加上需要执行的shell 命令
expect: 只有spawn 执行的命令结果才会被expect 捕捉到,因为spawn 会启
expect交互式创建账号密码的更多相关文章
- (转) mysql的连接,创建账号,修改密码
原文:http://blog.chinaunix.net/uid-20749043-id-1878306.html mysql的连接,创建账号,修改密码 2008-10-13 15:31:29 分类 ...
- Windows server 创建FTP 包括ftp的账号密码设置
原始文章 : https://blog.csdn.net/missingshirely/article/details/50767043 最近要做个FTP上传资源的工具,以前都是我提供目录,由公司网管 ...
- windows服务器中创建账号及管理相关的net命令
本文测试环境:windows server 2012 R2 Datacenter 实例要求: 1.创建账号,加入到远程桌面组,能实现远程桌面登录 2.指定Full name .及Description ...
- 账号密码管理系统Access版本
哈哈,花了我整整五天时间,账号密码管理系统软件终于成功编写完成了.由于我的各大论坛的账号密码特别多,记性又不好.所以一直以来都想要这么一个软件的,但是以前学习的都是面向过程的编程语言,一直无法实现这个 ...
- 如何在Windows 2003+IIS6的环境下找回应用程序池(application pool)中的服务账号密码
上一篇文章说了说如何在Win2008+iis7中取出SharePoint管理账号密码的方法. 整个过程简单的讲,就是通过使用要找回密码的账号用来在SharePoint中创建一个临时的Web Appli ...
- TCL/Expect交互式自动化测试概要 - - ITeye技术网站
TCL/Expect交互式自动化测试概要 - - ITeye技术网站 expect是一种基于TCL,能与交互式程序进行"可程序化"会话的脚本语言,是一种可以提供"分支和嵌 ...
- struts2的记住账号密码的登录设计
一个简单的基于struts2的登录功能,实现的额外功能有记住账号密码,登录错误提示.这里写上我在设计时的思路流程,希望大家能给点建设性的意见,帮助我改善设计. 登录功能的制作,首先将jsp界面搭建出来 ...
- C# ASP.NET MVC:使用Cookie记住账号密码
MVC记住账号密码 使用cookie操作 前端: <div> 用户名:<input type="text" id="UserName" val ...
- SQL Server遗失管理权限账号密码怎么办?
假如一个SQL Server实例只允许"SQL身份认证"模式登录数据库,而糟糕的是你忘记了sa的密码(sa出于安全考虑应该被禁用,这里仅仅为了描述问题)或其它具有sysadmin角 ...
随机推荐
- windows下gcc的安装
首先打开 www.mingw.org . www.mingw.org 直接点击右上方的 Download Installer 即可下载. 点击 Download Installer 进入下载页 ...
- HDU 1890 - Robotic Sort - [splay][区间反转+删除根节点]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1890 Time Limit: 6000/2000 MS (Java/Others) Memory Li ...
- python3学习笔记(2)_list-tuple
# !/usr/bin/env python3 # -*- coding:utf-8 -*_ #list 和 tuple #list 是有序集合,可以用索引(下标)访问lsit中的每一个元素 #最后一 ...
- sql优化实例(用左连接)
改为 也就是说用左连接代替where条件,这样的话效率会提高很多.
- vue学习六之vuex
由于状态零散地分布在许多组件和组件之间的交互中,大型应用复杂度也经常逐渐增长.为了解决这个问题,Vue 提供 vuex. 什么是Vuex Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式 ...
- ElasticSearch排序Java api简单Demo
代码: String time1 = ConstValue.GetCurrentDate(); SortBuilder sortBuilder = SortBuilders.fieldSort(&qu ...
- PAT 1066 Root of AVL Tree[AVL树][难]
1066 Root of AVL Tree (25)(25 分) An AVL tree is a self-balancing binary search tree. In an AVL tree, ...
- [LeetCode] 1. Two Sum_Easy tag: Hash Table
Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...
- [LeetCode] 496. Next Greater Element I_Easy tag: Stack
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n ...
- opencv3寻找最小包围矩形在图像中的应用-滚动条
#include<opencv2/opencv.hpp> #include<iostream> #include<vector> using namespace c ...