Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sh script except line error problem

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report