douzhang6646 2019-01-29 10:20
浏览 200
已采纳

从shell脚本按Enter后读取GoLang命令行参数

So I am using a OSS written in go which I don't have any exposure to. I am trying to automate that script.

SO this is how the script works calling_go_code Message for confirmation of user Get user input execute the code.

I am trying to automate this script.

So far this is what I have tried, sh test.sh Param1

When I am running the script like

echo "hello"
calling_go_code

The above code asks for some parameter as input test.sh

sh test.sh Param1

echo "hello"
calling_go_code -- $1
  • 写回答

1条回答 默认 最新

  • dongyuyi5680 2019-01-30 08:07
    关注

    Based on @RichardHuxton's post. This is the solution I am using

    #!/usr/bin/expect -f
    
    
    set alias [lindex $argv 1]
    
    set input [lindex $argv 0]
    
    set timeout -1
    
    COMMAND I AM USING 
    
    expect {
    
        "*CONFIRMATION MESSAGE 1" { send -- $alias }
    
    
        exp_continue
    
    }
    
    
    expect {
    
        "*CONFIRMATION MESSAGE 2" { send -- $alias }
    
    
        exp_continue
    
    }
    
    expect eof
    

    Calling bot

     ./bot param1 param2
    

    Dependency of Expect

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名