如何计算expect脚本中的命令行参数?
这是我的简单期望脚本:
#!/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
我该怎么做?谢谢!
This is my simple expect script:
#!/usr/local/bin/expect
puts "Argu 1 : [lindex $argv 0]"
Run
---
expect example.expt Testing
Output
------
Argu 1: Tesing
I need to count the arguments, which are passed by command line. Like this:
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
How can I do this? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
expect
使用 Tcl 作为其脚本语言。您正在寻找 llength 命令:expect
uses Tcl as its scripting language. You're looking for the llength command:迟到但我想会有用。
这也会打印命令行参数的数量和参数列表。
有关期望脚本的更多详细信息,请参阅此处
Late but will be useful i guess.
This prints the number of command line arguments and the arguments list as well.
More details about expect scripting can be found here