# 通过jenkins的apache用户rsync同步php代码到远程服务器报错如下:

SSH: EXEC: STDOUT/STDERR from command [/bin/sh /usr/local/worksh/jenkins_rsync/rsync_cc-product-api_cn.sh all ] ...
/usr/local/worksh/jenkins_rsync/rsync_cc-product-api_cn.sh: line : `product-api_rsync_all': not a valid identifier
SSH: EXEC: completed after ms
SSH: Disconnecting configuration [sz_platform01] ... # 确认问题,在jenkins服务器中模拟问题,确实报错了,但是在目标服务器 1.1..1中root切换到apache直接执行代码是没有问题的
猜测可能是jenkins发布代码时使用了 source /etc/profile 导致环境变量不同引发的问题 [apache@dev9_50:/root]$ ssh -p2025 apache@1.1.1.1 "/bin/sh /usr/local/worksh/jenkins_rsync/rsync_cc-product-api_cn.sh all"
apache@1.1.1.1's password:
/usr/local/worksh/jenkins_rsync/rsync_cc-product-api_cn.sh: line : `product-api_rsync_all': not a valid identifier
[apache@dev9_50:/root]$ # 具体的脚本如下
[root@sz_platform_web01:~]# cat /usr/local/worksh/jenkins_rsync/rsync_cc-product-api_cn.sh
#!/bin/bash ##############jenkins拉取git代码同步到 1.1..1_sz_platform_web01 上,然后触发 1.1..1_sz_platform_web01 上的该脚本进行 szali 内网机房同步####################
###### rsync product-api.chinasoft.com data ######################################
passwd="/data/www/.rsync/rsyncd.pass1"
exclude_list="--exclude=logs/ --exclude=cache/ --exclude=.git --exclude=.gitignore --exclude=.gitattributes --exclude=store_data/ --exclude=invoice_file/" # szali_product_api_ip szali_product_api_ip_list="172.18.54.136" ############################################################# # 同步所有机房
function product-api_rsync_all()
{
# rsync szali_product-api
for szali_product_api_ip in $szali_product_api_ip_list
do
echo "####################rsync szali_product-api start################################"
echo $szali_product_api_ip
rsync -zavP --delete $exclude_list --password-file=$passwd /data/www/vhosts/product-api.chinasoft.com/ apache@$szali_product_api_ip::apache/data/www/vhosts/product-api.chinasoft.com/
echo "################### rsync szali_product-api end #######################"
done } # 只同步深圳机房
function product-api_rsync_szali()
{
# rsync szali_product-api
for szali_product_api_ip in $szali_product_api_ip_list
do
echo "####################rsync szali_product-api start################################"
echo $szali_product_api_ip
rsync -zavP --delete $exclude_list --password-file=$passwd /data/www/vhosts/product-api.chinasoft.com/ apache@$szali_product_api_ip::apache/data/www/vhosts/product-api.chinasoft.com/
echo "################### rsync szali_product-api end #######################"
done
} ##################### MAIN ###############################
usage () {
echo ""
echo " Please Input server infomation!"
echo ""
echo " USAGE: `basename $0` [all|product-api_szali]"
echo ""
} if [ $# != ]
then
usage >&
exit
fi
OPT=$
case $OPT in
all)
echo "start rsync `basename $0` to all apiservice servers"
product-api_rsync_all
;;
apiservice_szali)
echo "start rsync `basename $0` to szali_product-api_servers"
product-api_rsync_szali
;; *)
echo "Usage:`basename $0` [all|product-api_szali]"
;;
esac # 经过反复修改,发现是中划线的问题,将函数名统一更换为下划线即可_
product-api_rsync_all --> 修改为 product_api_rsync_all product-api_rsync_szali --> 修改为 product_api_rsync_szali

centos6环境远程执行shell脚本报错not a valid identifier的问题处理的更多相关文章

  1. 执行shell脚本报错:syntax error near unexpected token `或syntax error: unexpected end of file

    引起此问题最可能的原因是: 在windows下编写的文件上传到linux执行. 我是在notepad++上编写的代码,之后上传到linux执行,报此错误.仔细检查,语法方面没有错误.上网查了一下,发现 ...

  2. shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory

    当我们把文件从windows系统中编辑的文件拷贝到linux系统中,如果我们执行文件会保存如下的错: shell脚本报错:-bash: xxx: /bin/bash^M: bad interprete ...

  3. shell脚本报错:"[: =: unary operator expected"

    shell脚本报错:"[: =: unary operator expected" 在匹配字符串相等时,我用了类似这样的语句: if [ $STATUS == "OK&q ...

  4. 解决执行sql脚本报错:没有足够的内存继续执行程序。

    出现执行sql脚本报错:没有足够的内存继续执行程序.是因为sql脚本过大,大家可能分为多个文件多次执行,这种笨方法可行,不过比较麻烦,大家可以用下面的方式,利用sqlcmd一次就行了:   执行cmd ...

  5. ubuntu终端执行shell脚本报command not found解决方法

    使用sudo执行脚本报错:sudo: myshell.sh: command not found 原因:发生这种情况的原因是因为您正在尝试执行的脚本需要正确的权限 解决:执行sudo chmod a+ ...

  6. windows 2012执行powershell脚本报错

    使用powershell运行脚本报错:进行数字签名.无法在当前系统上运行该脚本.有关运行脚本和设置执行策略的详细信息 修复方法:powershell "Set-ExecutionPolicy ...

  7. shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory

    今天执行一个shell脚本,然后在执行的时候报错,脚本内容很简单,仅供测试: #!/bin/sh echo "test shell " 具体报错信息如下 [root@localho ...

  8. Oracle 安装 RAC 11.2.0.4 centos7.4 -udev磁盘绑定/执行root脚本报错

    在centos 7.4上安装oracle rac 11.2.0.4 报错及相关解决 $ cat /etc/redhat-release CentOS Linux release 7.4.1708 (C ...

  9. Shell脚本报错:-bash: ./switch.sh: /bin/bash^M: bad interpreter: No such file or directory

    在学习shell中测试case参数命令代码如下 #!/bin/bash #switch测试 case $1 in     start)         echo 'start'     ;;      ...

随机推荐

  1. 使用AutoIt实现文件上传

    在网页上上传文件的时候,Selenium无法直接操作如Flash.JavaScript 或Ajax 等技术所实现的上传功能,这时候我们需要借用一个叫做AutoIt的软件来帮助我们事先自动化的上传操作. ...

  2. [转]Serverless实践

    转载的,原文: https://www.cnblogs.com/middleware/p/9470533.html ------------------------------------------ ...

  3. 项目(二)--完成练手feed流网站开发部署

    样式需要优化,最简版,还需新增逻辑. 点击跳转 源码

  4. Ubuntu常见服务启停

    停止rpcbind服务service portmap stop 停止nfs服务service nfs-kernel-server stop 停止Telnet服务/etc/xinetd.d/telnet ...

  5. iframe使用总结(实战)

    说在前面的话,iframe是可以做很多事情的.例如:a>通过iframe实现跨域;b>使用iframe解决IE6下select遮挡不住的问题c>通过iframe解决Ajax的前进后退 ...

  6. python_requests ~爬虫~小视频~~~

    当一只小小的Py_Spider也有一段时间了, 期间,更多的时间是在爬取图片啊, 文字, 文档这类的东西, 今天突然一时兴起, 来爬一手视频! 所以就找到了远近闻名的六间房(六扇门)哈哈,~~~ 1. ...

  7. MySQL 优化之EXPLAIN详解(执行计划)

    学习MySQL时我们都知道索引对于一个SQL的优化很重要,而EXPLAIN关键字在分析是否正确以及高效的增加了索引时起到关键性的作用. 这篇文章显示了如何调用“EXPLAIN”来获取关于查询执行计划的 ...

  8. jsp实现大文件上传分片上传断点续传

    1,项目调研 因为需要研究下断点上传的问题.找了很久终于找到一个比较好的项目. 在GoogleCode上面,代码弄下来超级不方便,还是配置hosts才好,把代码重新上传到了github上面. http ...

  9. 利用fgetc统计文件所在字节 和 总行数 和单词数

    #include <stdio.h> #include <stdlib.h> #define IS_WHITE_SPACE(c) ((c)==' '||(c)=='\t'||( ...

  10. 98: 模拟赛-神光 dp

    $code$ #include <cstdio> #include <cstring> #include <algorithm> using namespace s ...