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

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

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装