Automation script

expect evolved from tcl, it is a free programming tool used to realize automatic interactive tasks without human intervention. To put it bluntly, expect is a set of software used to realize automatic interactive functions.
When we run commands, scripts or programs, these commands, scripts or programs need to enter some instructions from the terminal to continue running, and these inputs need to be done manually. Using expect, you can simulate standard input and provide it to the program according to the prompt of the program, so as to realize automatic interactive execution.

Common commands

spawn starts a new process
expect to receive a string from the process
send is used to send a string to the process
interact command mainly Used to exit automation, enter manual interaction, need to be used with spawn
eof Exit command window

exp_continue loop matching

$argc represents the number of parameters
and the parameter value Stored in $argv, for example, the first parameter is [lindex $argv 0]

The conditional statement must be separated by a space< /span>
if {} {} eles {}

#!/bin/bash

mv
/home/duanyu/git/common_api/target/common_api-1.0.1.war /home/duanyu/git/common_api/target/ROOT.war

expect .
/combot.exp

#!/usr/bin/expect

set timeout 30
spawn scp
/home/duanyu/git/common_api/target/ROOT.war [email protected]192.168.1.46:/usr/local/commo_apache-tomcat-8.5.35_8080/webapps
expect {
"password:" {send "123\r"}
}
expect eof
spawn ssh [email protected]
192.168.1.46< span style="color: #000000;">
expect {
"password:" {send "123\r"}
}
expect {
"\\\$" {send "cd /usr/local/www /common_apache-tomcat-8.5.35_8080/logs \r"}
}
expect {
"\\\$" {send "sudo tail -f catalina.out \r"}
}
expect {
"Password:" {send "123\r"}
}

interact

#!/bin/bash

mv
/home/duanyu/git/common_api/target/common_api-1.0.1.war /home/duanyu/git/common_api/target/ROOT.war

expect .
/combot.exp

#!/usr/bin/expect

set timeout 30
spawn scp
/home/duanyu/git/common_api/target/ROOT.war [email protected]192.168.1.46:/usr/local/commo_apache-tomcat-8.5.35_8080/webapps
expect {
"password:" {send "123\r"}
}
expect eof
spawn ssh [email protected]
192.168.1.46< span style="color: #000000;">
expect {
"password:" {send "123\r"}
}
expect {
"\\\$" {send "cd /usr/local/www /common_apache-tomcat-8.5.35_8080/logs \r"}
}
expect {
"\\\$" {send "sudo tail -f catalina.out \r"}
}
expect {
"Password:" {send "123\r"}
}

interact

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2277 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.