#! /usr/bin/expect -f
# this script is used to practise the command "expect"

#when "lindex" have been used here, the array index begins with 0 but not with 1
set user [lindex $argv 0]
set host [lindex $argv 1]
set passwd [lindex $argv 2]
set timeout 10

spawn ssh $user@$host
# expect "[yes/no]" {send "yes\r"}  if 'ssh-ing' a server for the first time,

# you most likely encounter the case above concerning RSA
expect "password:" {send "$passwd\r"}
interact

# modify the script mode to be 0744

# now, one runs "./login.exp your_name host_name your_passwd" in the bash shell, logging in the server successfully.

the usage of linux command "expect"的更多相关文章

  1. 15 Examples To Master Linux Command Line History

    When you are using Linux command line frequently, using the history effectively can be a major produ ...

  2. 10 Interesting Linux Command Line Tricks and Tips Worth Knowing

    I passionately enjoy working with commands as they offer more control over a Linux system than GUIs( ...

  3. 5 commands to check memory usage on Linux

    Memory Usage On linux, there are commands for almost everything, because the gui might not be always ...

  4. [笔记]The Linux command line

    Notes on The Linux Command Line (by W. E. Shotts Jr.) edited by Gopher 感觉博客园是不是搞了什么CSS在里头--在博客园显示效果挺 ...

  5. A Complete Guide to Usage of ‘usermod’ command– 15 Practical Examples with Screenshots

    https://www.tecmint.com/usermod-command-examples/ -------------------------------------------------- ...

  6. linux command lynx

    [Purpose]        Learning linux command  lynx   [Eevironment]        Ubuntu 16.04 terminal   apt-get ...

  7. Linux command find All In One

    Linux command find All In One $ find -h # find: illegal option -- h # usage: # find [-H | -L | -P] [ ...

  8. linux tcl expect 安装(转)

    linux tcl expect 安装 一.Tcl安装 1.  下载:tcl8.4.20-src.tar.gz http://www.tcl.tk/software/tcltk/downloadnow ...

  9. 《The Linux Command Line》 读书笔记04 Linux用户以及权限相关命令

    Linux用户以及权限相关命令 查看身份 id:Display user identity. 这个命令的输出会显示uid,gid和用户所属的组. uid即user ID,这是账户创建时被赋予的. gi ...

随机推荐

  1. Python % 格式化字符串

    格式字符串 python 使用一个字符串作为模板 模板中含有格式符,为真实值预留位置 使用tuple或者字典来传递值 模板和值之间,用 % 来表示格式化操作 例子: 1) tuple 传值 print ...

  2. 【BZOJ-3996】线性代数 最小割-最大流

    3996: [TJOI2015]线性代数 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1054  Solved: 684[Submit][Statu ...

  3. DedeCMS Xss+Csrf Getshell \dede\file_manage_control.php

    目录 . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 对这个漏洞的利用方式进行简单的概括 . 这个漏洞的利用前提是需要登录到后台进行操作 ...

  4. Web 使用PostMan提交特殊格式数据

    使用PostMan 选择POST模式中的RAW模式 然后点击Headers添加Content-Type 类型比如是 application/json 然后就可以在body中以Json格式上传数据了 前 ...

  5. POJ 3061 Subsequence(尺取法)

    题目链接: 传送门 Subsequence Time Limit: 1000MS     Memory Limit: 65536K 题目描述 给定长度为n的数列整数以及整数S.求出总和不小于S的连续子 ...

  6. 提交 git 项目 到 github 在 centos 7

    Git 是分布式版本控制系统(Distributed Version Control System,简称 DVCS),它可以备份文件的历史信息,多个终端可以同时对文件作修改. 文件内容如果有了变化和之 ...

  7. sql总结一

    建表: select * from fruit; create table fruit ( id varchar(10) not null, name varchar(20) default '' n ...

  8. UI学习之常用方法(续)

    UIView 1.    UIView *vv = [[UIView alloc]initWithFrame:CGRectMake(100,100, 100, 30)]; [vv.layer setB ...

  9. BigDecimal数据加法返回值接收

    1.相加 两个BigDecimal变量a,b. 如果想进行相加,即a加b的话,返回值需要使用a进行接收,如下: a = a.add(b); BigDecimal为不可变类, 所以执行运算的结果需要再返 ...

  10. Git删除tag

    git tag -d v2016062101 删除本地tag git push origin --delete tag v2016062101 删除远程tag