代码之家  ›  专栏  ›  技术社区  ›  hellojoshhhy

无法验证分析为预期脚本的参数

  •  1
  • hellojoshhhy  · 技术社区  · 7 年前

    我是第一次编写Expect脚本,我希望有一个检查程序来验证用户参数。但我有以下错误,请告诉我,如果你知道哪里出了问题。谢谢

    #!/usr/bin/expect
    
    if {$argc != 1}
    {
            puts 'Insert IP address of tftp server'
            exit 1
    }
    

    这是个错误

    jeff@mymachine:/home/jeff~$ ./test.sh
    wrong # args: no script following "$argc != 1" argument
        while executing
    "if {$argc != 1}"
        (file "./test.sh" line 3)
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Colin Macleod    7 年前

    Expect基于Tcl。在编写代码时,Tcl解析器不知道 if

    if {$argc != 1} \
    {
        puts 'Insert IP address of tftp server'
        exit 1
    }
    

    if {$argc != 1} {
        puts 'Insert IP address of tftp server'
        exit 1
    }