git - git post receive hooks run remote server shell script error expecting keyword_do
问题描述
在以下帖子接收钩子下,我推送到存储库后确实收到错误, remote: hooks/post-receive:: syntax error, unexpected $undefined, expecting keyword_do or '{' or '('
发布接收脚本如下,
#!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
#!bin/bash
while read oldrev newrev ref \
do
(ssh user1@ip -pPassword\ 'path/to/the/shell.sh');
end
解决方案
对于while
bash 中的循环,您可以:
#!/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
部分是否正确,但我认为没有\
必要。
推荐阅读
- javascript - 如何在expo react native中将图像上传到firebase
- c++ - 是否有任何 C++ 函数可以对哈希表进行排序?
- android - 启用 PRODUCT_FULL_TREBLE_OVERRIDE 标志会影响 SELINUX 策略吗?
- python - Xpath没有给出结果scrapy python
- php - soapclient 请求 https 服务器错误,“您正在对启用 SSL 的服务器端口使用纯 HTTP”
- javascript - 如何在 Yarn 工作区的一个 package.json 文件中安装包?
- java - Spring批处理JobExecutionListener不起作用
- azure-logic-apps - ISE 中的逻辑应用程序 - 事件触发器(存储)不会触发,而 ISE 外部的逻辑应用程序会针对同一事件触发
- c++ - 如何创建从另一个线程到 Qt5 GUI 线程的 qDebug 信号
- reactjs - 样式 react-slick.neostack