git post接收钩子,运行远程服务器shell脚本错误,期望使用keyword_do

时间:2019-03-14 04:17:40

标签: git shell githooks

在以下帖子接收钩下,我在推送到存储库import turtle # Allows us to use turtles wn = turtle.Screen() # Creates a playground for turtles alex = turtle.Turtle() # Create a turtle, assign to alex alex.forward(50) # Tell alex to move forward by 50 units alex.left(90) # Tell alex to turn by 90 degrees alex.forward(30) # Complete the second side of a rectangle wn.exitonclick() # Wait for user to close (or click on) window

后确实出错

发布以下接收脚本,

remote: hooks/post-receive:: syntax error, unexpected $undefined, expecting keyword_do or '{' or '('

在这种情况下,我的远程服务器paswd包含#!bin/bash while read oldrev newrev ref \ do ssh user1@ip -pPassword\ 'path/to/the/shell.sh' end,我尝试了如下

\

#!bin/bash while read oldrev newrev ref do ssh user1@ip -pPassword\ 'path/to/the/shell.sh' end

2 个答案:

答案 0 :(得分:0)

对于bash中的while循环,您可以:

#!/bin/bash
while read oldrev newrev ref;do
    echo $read $oldrev $newrev $ref
done

#!/bin/bash
while read oldrev newrev ref
do
    echo $read $oldrev $newrev $ref
done

#!/bin/bash
while read oldrev newrev rev;do echo $read $oldrev $newrev $ref;done

我不确定ssh部分是否正确,但是我认为\不是必需的。

答案 1 :(得分:0)

  

我不确定ssh部分是否正确

实际上,ssh可能有效,但仍是问题的一部分:

  • 从接收后挂钩所在的服务器上执行时,检查ssh -T user1@ip -pPassword是否工作
  • 静默地检查确实有效,这意味着user1 .bashrc.profile不会回显一堆字符串,这可能会干扰钩子执行。 li>