Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Sh script except line error problem

Shulou Source: shulou.com Published: 2022-06-01 03:59:54 10月06日 Update

Content of the script:

[root@m01 scripts] # cat fenfa_sshkey.exp

[root@m01 scripts] # cat fenfa_sshkey.exp

#! / usr/bin/expect

If {$argc! = 2} {

Send_user "usage: expect fenfa_sshkey.exp file host\ n"

Exit

}

# define var

Set file [lindex $argv 0]

Set host [lindex $argv 1]

Set password "123456"

Spawn ssh-copy-id-I $file "$host"

Expect {

"yes/no" {send "yes\ r"; exp_continue}

"* password" {send "$password\ r"}

}

Expect eof

Exit-onexit {

Send_user "Oldboy say good bye to you!\ n"

}

Execute the script and report an error

[root@m01 scripts] # / bin/sh-x / server/scripts/fenfa_sshkey.exp

/ server/scripts/fenfa_sshkey.exp: line 15: syntax error near unexpected token `}'

/ server/scripts/fenfa_sshkey.exp: line 15: `}'

Solution:

It's just an extra space, that's all.

Tags: Script content method space line newspaper question Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple Shulou Technology OPPO Reno Huawei