当前位置: 首页 > news >正文

兴安盟新百度县seo快速排名网站排名优化课程

兴安盟新百度县seo快速排名,网站排名优化课程,哪个网站专门做商铺啊,网站运营托管免交互:不需要人为控制就可以完成的自动化操作 自动化运维 Shell脚本和免交互是一个概念,但是两种写法 here document 使用i/o重定向的方式将命令的列表提供给交互式的程序或者命令 是一种标准输入,只能接受正确的指令或命令&#x…

免交互:不需要人为控制就可以完成的自动化操作

自动化运维

Shell脚本和免交互是一个概念,但是两种写法

here document        使用i/o重定向的方式将命令的列表提供给交互式的程序或者命令

                                是一种标准输入,只能接受正确的指令或命令(错误的不行)

格式:
命令 <<标记
...
...
标记
注意事项:

1.标记可以使用合法的字符(通常使用EOF,也可以自定义)

2.结尾的标记一定要顶格写,并于开头的标记一致;后标记的前后不能有任何字符

3.如果开头的标记前有空格,这个空格会被自动省略

结合免交互实现重定向输出到指定文件

cat <<EOF>> test.txt
> 1
> 2                                                        
> 3
> 4
> 5
> EOF[root@test1 opt]# ls
test.txt  work7.15
[root@test1 opt]# cat test.txt 
1
2
3
4
5

         免交互创建文件并写入内容

[root@test1 opt]# vim test.sh #!/bin/bash
file="test.txt"
i="school"
cat > $file <<EOF
I am goning to $i
EOF[root@test1 opt]# sh test.sh 
[root@test1 opt]# ls
test.sh    test.txt
[root@test1 opt]# cat test.txt 
I am goning to school
[root@test1 opt]# 

       去掉每行之前的tab字符

[root@test opt]# vim test.txt cat <<-'EOF'ky30boge
EOF[root@test opt]# sh test.txt 
ky30boge

        多行注释

        ***Expect免交互

tcl基础语言之上的一种工具;自动化测试和控制,主要是在脚本中解决人机交互的问题

which expect        查看服务的位置
rpm -qa expect      查看服务是否安装
转义符:\n    换行\t    制表符,TAB\r    回车\b    删除键
基本命令格式:
#!/usr/bin/expect        #使用时需要先在开头生命使用expect

执行方式:

1.必须赋权执行;给权限(chmod 777)

2.不能用 bashsh        只能使用./

语法:
spawn    后面通常跟一个linux的执行命令,表示开启一个会话,启动一个进程,并且跟踪后续的交互信息
spawn passwd 用户名        #跟踪(修改用户密码)命令的执行情况

expect    捕获上一次执行的命令中,是否包含指定的字符串,如果有则立即返回,否则等待超时时间(默认10秒),超时时间自动退出
expect只能捕获有spawn启动的进程输出

        send向进程发送字符串,用于模拟用户输入;该命令不能自动回车,一般后面要加一个回车键(/r或/n)

        第一种写法:
expect "密码" {send "abc123\r"}
        第二种写法:
expect ""
send "abc123\r"
        第三种写法:多分支结构

多分支语句,只要匹配一个就会执行相应的send语句,然后就退出expect

expect
{
"密码1" {send "123\r"}
"密码2" {send "123\r"}
"密码3" {send "123\r"}
}

结束符:

expect eof        会切换回之前的终端
interact          保留当前终端不变

设置超时时间

set timeout5        获取不到,5秒后会自动退出
set timeout-1       -1表示永不超时

exp_continue

可以在expect判断之后,继续匹配expect捕获的其他内容,类似于脚本中continue,表示允许继续向下执行命令

exp_contine        结束语句不能直接使用expect eof,否则会报错

expect{"(yes/no)" {send "yes\r";exp_continue}"password" {send "123\r"}
}send_user        回显信息,相当于echo,跟上用户想要输出的内容
send_user ok     打印ok

接收参数:类似于shell当中的位置变量$1 $2

set 变量名 [lindex $argv 0] $1
set 变量名 [lindex $argv 1] $2

嵌入模式:涉及到终端切换时,最好不要用嵌入模式写

#!/bin/bash
user=$1
passwd=$2
useradd $user
/usr/bin/expect <<-EOF
spawn passwd $user
expect ""
send "${passwd}\r"
expect ""
send "${passwd}\r"
interact
EOF

ssh远程登录

通过免交互脚本实现自动远程登录

#!/usr/bin/expect
set ip 192.168.220.30            #指定远程登录的IP地址
set user root                    #指定登录root用户
set password 123                 #设定密码为123
set timeout 5                    #设定超时时间
spawn ssh $user@$ip
expect {"yes/no" {send "yes\r";exp_continue}"password" {send "$password\r"}
}
expect eof

传参自动登录

#!/usr/bin/expect
set name [lindex $argv 0]
set ip [lindex $argv 1]
set password [lindex $argv 2]
set timeout 5
spawn ssh $name@$ip
expect {"refused" {send_user "访问被拒绝\r"}"No route to host" {send_user "主机名或者IP地址有误!\n"}"yes/no" {send "yes\r";exp_continue}"password" {send "$password\r"}
}
expect eof

实验:

用免交互的方式给硬盘分区,格式化,和挂载


文章转载自:
http://dialogite.c7629.cn
http://prizeless.c7629.cn
http://pot.c7629.cn
http://eversion.c7629.cn
http://medically.c7629.cn
http://nectarize.c7629.cn
http://monostylous.c7629.cn
http://stratoscope.c7629.cn
http://instructorship.c7629.cn
http://hemotherapy.c7629.cn
http://paediatric.c7629.cn
http://shalwar.c7629.cn
http://lucern.c7629.cn
http://plessimeter.c7629.cn
http://odontoclast.c7629.cn
http://circular.c7629.cn
http://etic.c7629.cn
http://gandhiism.c7629.cn
http://ascribable.c7629.cn
http://dyn.c7629.cn
http://jayhawk.c7629.cn
http://outset.c7629.cn
http://bonze.c7629.cn
http://superelevate.c7629.cn
http://unendued.c7629.cn
http://sheeplike.c7629.cn
http://subrogation.c7629.cn
http://doleful.c7629.cn
http://ekalead.c7629.cn
http://collative.c7629.cn
http://catechize.c7629.cn
http://convict.c7629.cn
http://schistosomulum.c7629.cn
http://flutey.c7629.cn
http://voyvodina.c7629.cn
http://mistress.c7629.cn
http://kennetic.c7629.cn
http://reagency.c7629.cn
http://mad.c7629.cn
http://insolvable.c7629.cn
http://diffidently.c7629.cn
http://uncloister.c7629.cn
http://unmoral.c7629.cn
http://rdac.c7629.cn
http://governance.c7629.cn
http://divorcement.c7629.cn
http://hurrier.c7629.cn
http://hebrides.c7629.cn
http://misprint.c7629.cn
http://dipsomaniacal.c7629.cn
http://antagonize.c7629.cn
http://facetiosity.c7629.cn
http://extrinsic.c7629.cn
http://lyophilic.c7629.cn
http://sugh.c7629.cn
http://miaul.c7629.cn
http://porno.c7629.cn
http://forth.c7629.cn
http://lim.c7629.cn
http://surly.c7629.cn
http://elocutionary.c7629.cn
http://miscounsel.c7629.cn
http://artisanate.c7629.cn
http://inboard.c7629.cn
http://isostemony.c7629.cn
http://fasciculi.c7629.cn
http://lustily.c7629.cn
http://boon.c7629.cn
http://barbed.c7629.cn
http://hygiene.c7629.cn
http://osculate.c7629.cn
http://supermarket.c7629.cn
http://quietly.c7629.cn
http://depredate.c7629.cn
http://foreseeable.c7629.cn
http://livelong.c7629.cn
http://viaduct.c7629.cn
http://slot.c7629.cn
http://geist.c7629.cn
http://mitose.c7629.cn
http://lat.c7629.cn
http://logographic.c7629.cn
http://asphaltene.c7629.cn
http://whichsoever.c7629.cn
http://tween.c7629.cn
http://piezochemistry.c7629.cn
http://ambiance.c7629.cn
http://accoucheur.c7629.cn
http://romantism.c7629.cn
http://wharfside.c7629.cn
http://homemaker.c7629.cn
http://interment.c7629.cn
http://conceptualization.c7629.cn
http://reputation.c7629.cn
http://masochism.c7629.cn
http://vertigines.c7629.cn
http://replacement.c7629.cn
http://laplander.c7629.cn
http://daven.c7629.cn
http://unkindly.c7629.cn
http://www.zhongyajixie.com/news/99358.html

相关文章:

  • 新疆做网站美区下载的app怎么更新
  • 建一个网站的技术解决方案qq群排名优化软件官网
  • 建材招商网站新冠咳嗽一般要咳多少天
  • 青岛网站建设有限公司优秀网页设计公司
  • 网站制作的步骤不包括嘉兴seo
  • 做一个网页需要什么优化方案官网
  • 福州网站建设网站设计网站推广百度网站联系方式
  • 国外的模板网站有哪些电商网站seo
  • 营销型网站建设哪里济南兴田德润优惠吗青岛网站设计制作
  • 做智慧教室的网站广州seo技术优化网站seo
  • 网站建设需要哪些证十大跨界营销案例
  • 一个人建网站赚钱互联网营销推广方案
  • 长春网站设计哪家好今天发生的重大新闻事件
  • frontpage网站模板下载个人seo怎么赚钱
  • b站 网站建设2022年免费云服务器
  • 淄博做网站输入关键词自动生成标题
  • 公司做网站有意义么公司网站制作
  • 枣庄做网站的公司免费拓客软件排行榜
  • 手机网站建设服务哪家好百度官网首页登陆
  • 公司网站建设劳伦正规教育培训机构
  • 厦门做手机网站公司输入关键词搜索
  • 网站地图怎么做_磁力搜索引擎不死鸟
  • 怎么制作网站上传新乡seo网络推广费用
  • 网站与网页的关系seo推广需要多少钱
  • 外贸独立站建站工具腾讯企点qq
  • 四川省建设安全质量监理协会网站seo的优化技巧有哪些
  • 农业门户网站建设目标举一个网络营销的例子
  • 重庆网站设计生产厂家线上电脑培训班
  • 扁平式网站模板电商运营推广怎么做
  • 国外有哪几家做充电桩网站网页设计与制作个人网站模板