这是我的简单期望脚本:
#!/usr/local/bin/expect
puts "Argu 1 : [lindex $argv 0]"
Run
---
expect example.expt Testing
Output
------
Argu 1: Tesing
Run Code Online (Sandbox Code Playgroud)
我需要计算命令行传递的参数。像这样:
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
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?谢谢!
expect使用Tcl作为其脚本语言。您正在寻找llength命令:
puts "Total: [llength $argv] argument(s)"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10286 次 |
| 最近记录: |