expect交互式脚本编写

2022-01-12 14:47:05 浏览数 (1)

代码语言:javascript复制
#!/usr/bin/expect


set full_name [lrange $argv 0 0]
set domain_name [lrange $argv 1 1]
set Organization_name [lrange $argv 2 2]
set Generic_name [lrange $argv 3 3]

spawn openssl req -new -newkey rsa:2048 -nodes -keyout $Generic_name.key -out $Generic_name.csr
expect "]:"
send "cnr"
expect "]:"
send "$full_namer"
expect "]:"
send "$full_namer"
expect "]:"
send "$Organization_namer"
expect "]:"
send "opsr"
expect "]:"
send "$domain_namer"
expect "]:"
send "r"
expect "]:"
send "r"
expect "]:"
send "r"
expect eof

0 人点赞