Shell script login template description, shell script Template
Write notepad and change the file suffix to sh
#! /Usr/bin/CT
# Log on to ssh
# Use the ssh server spawn in combination with Alibaba CT and send
Spawn ssh root @ ip
# Expectation
Reset CT "password :"
# Enter the password and click Enter \ n
Send "tktktktkt \ n"
# Izhp1_z74iw8bsizduk8mdz
CT "izhp1_z74iw8bsizduk8mdz :"
# Input ls/
Send "ls/\ n"
# Expectation
CT "izhp1_z74iw8bsizduk8mdz :"
# Input
Send "cd/usr/local \ n"
# Expectation/home
CT "/usr/local"
# Input ls
Send "tar-xvf jdk1.8.0_151.tar \ n"
# Expectation
CT "/usr/local"
# Input content to the file
Send "cd/etc \ n"
# Expect etc
CT "/etc"
# Input the configuration environment to the profile
Send "echo export JAVA_HOME =/usr/local/jdk1.8.0 _ 151> profile \ n"
# Expect etc
CT "/etc"
# Input the configuration environment to the profile
Send "echo export CLASSPATH =. :/usr/local/jdk1.8.0 _ 151/lib/dt. jar:/usr/local/jdk1.8.0 _ 151/lib/tools. jar> profile \ n"
# Expect etc
CT "/etc"
# Input the configuration environment to the profile
Send "echo export PATH =/usr/local/jdk1.8.0 _ 151/bin: \ $ PATH> profile \ n"
# Input the system to reload the configuration file
# Expect etc
CT "/etc"
# Reload the configuration file
Send "source profile \ n"
# Enter java-version to check the jdk Environment
# Expect etc
CT "/etc"
# Reload the configuration file
Send "java-version \ n"
# Stay on the server
Interact