expect

How to run a TCL script to tell run in every 10 minutes?

主宰稳场 提交于 2020-01-04 05:18:25
问题 My TCL script: source reboot_patch.tcl set a 1 while {$a < 10} { exec reboot_patch.tcl after 60000 incr a } I need to run "reboot_patch.tcl" script for every 1 min in my system. I wrote above script. But its running only once and its coming out. Following is the "reboot_patch.tcl" script: #!/usr/bin/tcl package require Expect spawn telnet 40.1.1.2 expect "*console." send "\r" expect "*ogin:" send "test\r" expect "*word:" send "test\r" expect "*>" send "clear log\r" expect "*#" send "commit \r

实现两种登录方式一键切换的脚本及相关知识点

你说的曾经没有我的故事 提交于 2020-01-02 15:51:33
公司测试环境有两种登录模式,未实现脚本一键切换之前,都需要手动修改网关配置、中间件域下的appr.properties文件、外网参数配置,且需去控制台重启用户登录对接程序包,过程繁琐;实现脚本切换后,可以快速切换。 一、执行outin.sh脚本 如下图,执行.sh脚本后选择切换的模式,则实现自动切换!!! 对应的outin.sh脚本如下图: 1 #!/bin/bash 2 echo -e "\033[33m 请输入你需要的操作 \033[0m" #输出字符串 3 echo -e "\033[33m 1.切换成本地登录 2.切换成统一认证\033[0m" 4 echo -e "\033[33m ------------------------------------------- \033[0m" 5 read type #读取键盘输入的变量 6 if [ $type == 2 ] ; then #根据键盘输入的值来执行脚本 7 echo "开始切换统一认证" 8 cd $(pwd)/login #切换到路径 9 ./out.sh #执行out.sh脚本 10 echo "数据库修改完成" 11 cd /u01/ZWWG 12 sed -i 's/local-login: 1/local-login: 0/g' application.yml

Exit status code for Expect script called from Bash

杀马特。学长 韩版系。学妹 提交于 2020-01-02 14:05:06
问题 I made a Bash script which uses an expect script to automate ssh logins.The script connects to multiple servers and runs some commands. The bash script prompts for login credentials once. I want to incorporate a feature wherein the script terminates if the login fails for the first server to avoid the script checking for next servers resulting in the user account getting locked. The account lockout happens for 3 consecutive login failures and the number of server the script tries to connect

Exit status code for Expect script called from Bash

流过昼夜 提交于 2020-01-02 14:04:34
问题 I made a Bash script which uses an expect script to automate ssh logins.The script connects to multiple servers and runs some commands. The bash script prompts for login credentials once. I want to incorporate a feature wherein the script terminates if the login fails for the first server to avoid the script checking for next servers resulting in the user account getting locked. The account lockout happens for 3 consecutive login failures and the number of server the script tries to connect

execute local script on remote server in expect

廉价感情. 提交于 2020-01-02 09:52:29
问题 I want to execute my local script on remote server. #!/usr/bin/expect -f set idNhost [lindex $argv 0] set password [lindex $argv 1] eval spawn ssh $idNhost \'bash -s\' < a.sh expect -re "password" send "$password\r" interact But expect interpret each argument as a single commend. So it find script on remote server. Please help me.... 回答1: Try like this: spawn bash -c "ssh $idNhost bash -s < a.sh" 回答2: You can first send your script to remote server then attach a shell and execute it from

Why do I get a segmentation fault in my simple c++ program using libexpect.so?

白昼怎懂夜的黑 提交于 2020-01-01 09:10:12
问题 I am busy with a project where I have to automate some processes in bash or ssh so I decided to use the libexpect.so library. If you don't know what libexpect is, it provides an expect extension that I can use in a c++ program, and expect is just a program where you can run automated scripts for things like ssh. So I can execute a script which attempts to ssh somewhere...when the password prompt is found by expect I could have already given expect a password to send. My problem is that when I

How can I encrypt or hide passwords in a Perl script?

ぐ巨炮叔叔 提交于 2020-01-01 04:53:08
问题 I am working on Perl script that uses Expect to login via telnet to remote machines (don't ask, gotta use telnet). I also do perforce p4 login operations as necessary and use expect to pipe in the correct passwords. For now I just read passwords from clear text environment variable, i.e. export PASSWORD=password , which I know is no good security wise. What's the best way to store passwords for scripts like these that need a lot of passwords for multiple systems? Encrypted in a text file

How to use bash/expect to check if an SSH login works

南笙酒味 提交于 2020-01-01 04:41:05
问题 My team manages many servers, and company policy dictates that the passwords on these servers must be changed every couple of weeks. Sometimes, our official database of passwords gets out of date for whatever reason (people forget to update it, usually), but we cannot identify this sometimes until months later, since we don't consistently use every server. I want to write a script that will scrape the passwords from the database, and use those passwords to attempt an (ssh) login to each

Can I use a heredoc to enter a password in bash?

若如初见. 提交于 2019-12-31 02:18:06
问题 I know about RSA authentication, but for my purposes I want to use a heredoc to specify the password. I want something like the following, but I can't get it to work. Is this even possible? #!/bin/bash echo -n "Enter Password: " read -s password ssh myhost << EOL $password echo "I'm logged onto myhost" EOL echo done This is what I get when I try it: $ ./testssh Enter Password: Pseudo-terminal will not be allocated because stdin is not a terminal. user@myhost's password: Warning: No xauth data

Parsing command line using argc and argv in expect

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-31 01:55:10
问题 I have an expect routine, which needs to spawn a process and pass the command line arguments I passed to the expect routine to the spawned process. My expect routine has the following line spawn myProcess $argv and when I call my expect routine I call it from the command line as follows expect myRoutine <arg1> <arg2> <arg3> When I do this, expect throws the following error Can't open input file <arg1> <arg2> <arg3> for reading However if I change my expect routine as follows spawn myProcess