centos6环境远程执行shell脚本报错not a valid identifier的问题处理
# 通过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的问题处理的更多相关文章
- 执行shell脚本报错:syntax error near unexpected token `或syntax error: unexpected end of file
引起此问题最可能的原因是: 在windows下编写的文件上传到linux执行. 我是在notepad++上编写的代码,之后上传到linux执行,报此错误.仔细检查,语法方面没有错误.上网查了一下,发现 ...
- shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory
当我们把文件从windows系统中编辑的文件拷贝到linux系统中,如果我们执行文件会保存如下的错: shell脚本报错:-bash: xxx: /bin/bash^M: bad interprete ...
- shell脚本报错:"[: =: unary operator expected"
shell脚本报错:"[: =: unary operator expected" 在匹配字符串相等时,我用了类似这样的语句: if [ $STATUS == "OK&q ...
- 解决执行sql脚本报错:没有足够的内存继续执行程序。
出现执行sql脚本报错:没有足够的内存继续执行程序.是因为sql脚本过大,大家可能分为多个文件多次执行,这种笨方法可行,不过比较麻烦,大家可以用下面的方式,利用sqlcmd一次就行了: 执行cmd ...
- ubuntu终端执行shell脚本报command not found解决方法
使用sudo执行脚本报错:sudo: myshell.sh: command not found 原因:发生这种情况的原因是因为您正在尝试执行的脚本需要正确的权限 解决:执行sudo chmod a+ ...
- windows 2012执行powershell脚本报错
使用powershell运行脚本报错:进行数字签名.无法在当前系统上运行该脚本.有关运行脚本和设置执行策略的详细信息 修复方法:powershell "Set-ExecutionPolicy ...
- shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
今天执行一个shell脚本,然后在执行的时候报错,脚本内容很简单,仅供测试: #!/bin/sh echo "test shell " 具体报错信息如下 [root@localho ...
- 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 ...
- 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' ;; ...
随机推荐
- 在线研讨会预热 | 基于ASPICE&CNAS的单元测试介绍
随着新能源车.智能驾驶技术的快速发展,软件本身复杂度越来越高,应用场景也是复杂多样,如何保证软件质量对我们来说是一个严峻的挑战.软件测试作为软件质量保证的重要手段,被各大整车厂和供应商 ...
- Oracle数据库的分页
Oracle的分页 ORACLE支持一个关键字ROWNUM,ROWNUM是一个伪列,该列不存在于任何一张表中,但是每张表都可以查询该列. 而该列在结果集的中值是结果集中每条记录的"行号&qu ...
- Django --- ORM表查询
目录 使用数据库之前的配置工作 单表操作常用的方法 一对多字段的增删改查 多对多字段数据的增删改查 跨表查询 聚合函数 分组查询 F与Q查询 使用数据库之前的配置工作 settings.py中的配置 ...
- 基于Python3+Requests的贴吧签到助手
因为总是忘记签到,所以尝试写了一个签到脚本,因为使用的是Python3,所以没法使用Urllib2,于是选择了Requests,事实证明,Requests比Urllib2好用.整体思路比较简单,就是模 ...
- [RxJS] Groupby operator
The use case is similar to Twitter "like" button, you can click "click" button o ...
- 学到了林海峰,武沛齐讲的Day35 完 协程
day3 requests.get 爬网页 greenlet 协程模块 还有asy!!!模快(后续版本) day4 事件驱动 day5 基础学习 day6 基础学习 da ...
- 洛谷 P1140 相似基因 题解
每日一题 day23 打卡 Analysis dp[i][j]表示序列A中前i个与序列B中前j个匹配的相似度最大值 所以,dp方程很容易想到: 1.让a[i]与b[j]匹配 2.让a[i]与B序列中一 ...
- TPC-H简介
TPC-H是事务处理性能委员会( Transaction ProcessingPerformance Council )制定的基准程序之一,TPC- H 主要目的是评价特定查询的决策支持能力,该基准模 ...
- 自用ajxa 后台管理请求
/** * 保存或者修改商品信息 * @returns */ function saveOrUpdateBaseGoodInfo(){ var json={}; var goodName=$.trim ...
- BZOJ 3625:小朋友和二叉树 多项式开根+多项式求逆+生成函数
生成函数这个东西太好用了~ code: #include <bits/stdc++.h> #define ll long long #define setIO(s) freopen(s&q ...