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' ;; ...
随机推荐
- 下载nvidia-docker2的rpm包
现在慢慢进入GPU的世界, 参考安装URL: https://github.com/NVIDIA/nvidia-docker # If you have nvidia-docker 1.0 insta ...
- 转 C#关于DateTime得到的当前时间的格式和用法
DateTime.Now.ToShortTimeString() DateTime dt = DateTime.Now; dt.ToString();//2005-11-5 13:21:25 dt.T ...
- 1211 BBS后台管理文章添加
目录 昨日内容回顾 侧边栏inclusion_tag inclusion_tag的响应 使用 自定义inclusion_tag,标签,过滤器 文章的点赞点踩 前端 后端 校验规则 文章的评论功能 1. ...
- mysql 两张表字段模糊匹配--字符串拼接函数
concat(A,B,C,...) 拼接字符串 例如concat('123','***','345') =>123***345 SELECT concat( substr(t1.CODE, ...
- Flask - flask-script | 多app应用 | wtforms
flask-script 用于实现类似于django中 python3 manage.py runserver ...类似的命令 安装 >: pip3 install flask-script ...
- select下拉选中显示对应的div隐藏不相关的div
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- LightOJ - 1369 - Answering Queries(规律)
链接: https://vjudge.net/problem/LightOJ-1369 题意: The problem you need to solve here is pretty simple. ...
- Map的常用实现类及Entry的用法
public static void main(String[] args) { //map 键值对 json格式根据你的键名来获取对应的值 //特点 :无序.以键值对的形式添加元素,键不 ...
- SSM整合Dubbo案例
一.Consumer子类 MyController类 @Controller @RequestMapping("/login") public class MyController ...
- NOIP前做题记录
鉴于某些原因(主要是懒)就不一题一题写了,代码直接去\(OJ\)上看吧 CodeChef Making Change 传送门 完全没看懂题解在讲什么(一定是因为题解公式打崩的原因才不是曲明英语太差呢- ...