#! /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. 【BZOJ-2521】最小生成树 最小割

    2521: [Shoi2010]最小生成树 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 415  Solved: 242[Submit][Statu ...

  2. css选择器(选择<div>内所有<p>元素)

    情况1:<div><p></div> 情况2:<div><a><p></p></a></div&g ...

  3. oracle sqlplus 连接不正常

    场景描述:在开始--运行--输入SQLPLUS 登陆不了报警:“WINDOWS找不到文件‘SQLPLUS’. 原因分析:一般出现这种情况可能的原因: 1.文件名有问题 2.路径有问题 3.安装有问题 ...

  4. Oracle技术嘉年华

    只有把一件事情做好,才会获得更多的机会! 短期的努力,成效并不明显,但是自己的成长一定能够感受到! 嘉年华的收获: 遗憾: 总结: 展望:

  5. poj3335 半平面交

    题意:给出一多边形.判断多边形是否存在一点,使得多边形边界上的所有点都能看见该点. sol:在纸上随手画画就可以找出规律:按逆时针顺序连接所有点.然后找出这些line的半平面交. 题中给出的点已经按顺 ...

  6. 洛谷P2853 [USACO06DEC]牛的野餐Cow Picnic

    题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ 100) cows is grazing in one of N ...

  7. java编译错误 程序包javax.servlet不存在javax.servlet.*

    java编译错误 程序包javax.servlet不存在javax.servlet.* 编译:javac Servlet.java 出现 软件包 javax.servlet 不存在 软件包javax. ...

  8. [Android] View.setTag(key,Object) (java.lang.IllegalArgumentException: The key must be an application-specific resource id.)

    转自: http://blog.csdn.net/brokge/article/details/8536906 setTag是android的view类中很有用的一个方法,可以用它来给空间附加一些信息 ...

  9. Linux进程关闭和后台运行解析

    1.问题背景 Java是跨平台的,大部分程序也都是在Linux服务器上运行的.但是很多朋友其实对服务器了解并不多,对相关知识也是一知半解.很多概念可能知道,但是并不十分清楚,仅仅是基本运用.可能很多新 ...

  10. linux下安装zookeeper(单机版)

    Zookeeper 分布式服务框架是用来解决分布式应用中经常遇到的一些数据管理问题,如:统一命名服务.状态同步服务.集群管理.分布式应用配置项的管理等.本文主要从使用者角度来介绍一下Zookeeper ...