gpt4 book ai didi

expect - 如何计算期望脚本中的命令行参数?

转载 作者:行者123 更新时间:2023-12-01 01:30:05 27 4
gpt4 key购买 nike

这是我的简单期望脚本:

#!/usr/local/bin/expect
puts "Argu 1 : [lindex $argv 0]"

Run
---
expect example.expt Testing

Output
------
Argu 1: Tesing

我需要计算命令行传递的参数。像这样:
expect example.expt 1 2 3 4

I need the script for the following output
Total: 4 arguments
Arg1: 1
Arg2: 2
Arg3: 3
Arg4: 4

我怎样才能做到这一点?谢谢!

最佳答案

expect用途 Tcl作为它的脚本语言。您正在寻找 llength命令:

puts "Total: [llength $argv] argument(s)"

关于expect - 如何计算期望脚本中的命令行参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5351805/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com