用户如何期望并发送请求和睡眠
how to user expect and send with a request and sleep
密码出现时
我想使用 expect 在 5s
后自动输入请求的结果
macOS shell 期望
expect << !
set timeout -1
spawn bundle exec fastlane fastlane-credentials add --username sakura
expect "*Password*"
sleep 5
send `curl http://localhost/a.txt`
interact
!
睡眠不能影响
密码前用curl http://localhost/a.txt
,我要在
后
在tcl语言中,每次都发送命令解释,所以休眠将无法与您的进程交互。在 expect 应该工作之前先睡觉,但你需要将密码保存在临时文件中作为存储。更多详细信息,示例代码显示为:
#!/usr/bin/expect
set timeout -1
spawn bundle exec fastlane fastlane-credentials add --username sakura
sleep 5
send_user "[exec curl -s http://localhost/a.txt -o /tmp/_passwd.txt]"
set fp [open "/tmp/_passwd.txt" r]
set passwd [read $fp]
close $fp
send_user "[exec rm -f /tmp/tmp/_passwd.txt]"
puts $passwd
expect "*Password*"
send '$passwd\r'
interact
密码出现时 我想使用 expect 在 5s
后自动输入请求的结果macOS shell 期望
expect << !
set timeout -1
spawn bundle exec fastlane fastlane-credentials add --username sakura
expect "*Password*"
sleep 5
send `curl http://localhost/a.txt`
interact
!
睡眠不能影响
密码前用curl http://localhost/a.txt
,我要在
在tcl语言中,每次都发送命令解释,所以休眠将无法与您的进程交互。在 expect 应该工作之前先睡觉,但你需要将密码保存在临时文件中作为存储。更多详细信息,示例代码显示为:
#!/usr/bin/expect
set timeout -1
spawn bundle exec fastlane fastlane-credentials add --username sakura
sleep 5
send_user "[exec curl -s http://localhost/a.txt -o /tmp/_passwd.txt]"
set fp [open "/tmp/_passwd.txt" r]
set passwd [read $fp]
close $fp
send_user "[exec rm -f /tmp/tmp/_passwd.txt]"
puts $passwd
expect "*Password*"
send '$passwd\r'
interact