开发者

bash: ./mysql_exe.sh: line 13: syntax error: unexpected end of file

开发者 https://www.devze.com 2023-03-14 20:58 出处:网络
everyone. I\'m a bash script noob, and I\'m failing to figure out why I\'m getting an unexpected end of file error.

everyone.

I'm a bash script noob, and I'm failing to figure out why I'm getting an unexpected end of file error.

This is my script:

#!/bin/bash

server=8100

while [ $server -le 8121 ]
do
        ssh pos$server <<ENDEXP
        mysql -u root -p12345 pos开发者_如何学Python_master_prod <<ENDEXP
        show slave status \G <<ENDEXP
        \q <<ENDEXP
        server=$(( $server + 1 ))
done

Any ideas?

Thanks!!


If I understand what it's supposed to do, this should work:

#!/bin/bash

for ((server=8100; server <= 8121; server++)); do
    ssh pos$server <<-ENDEXP
        mysql -u root -p12345 pos_master_prod
        show slave status \G
        \q
    ENDEXP
done

(Note: be sure the lines to be sent to the remote server are indented with tabs, not spaces; <<- removes leading tabs, but not other forms of indentation.)


Looks like you want to use a here-doc but the syntax is a bit off..

0

精彩评论

暂无评论...
验证码 换一张
取 消