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' ;; ...
随机推荐
- python中的嵌套类
python中的嵌套类 在.NET和JAVA语言中看到过嵌套类的实现,作为外部类一个局部工具还是很有用的,今天在python也看到了很不错支持一下.动态语言中很好的嵌套类的实现,应该说嵌套类解决设计问 ...
- Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'phone' at row 1
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'phone ...
- 三种Timer
一.基于 Windows 的标准计时器(System.Windows.Forms.Timer) 首先注意一点就是:Windows 计时器是为单线程环境设计的.它直接继承自Componet.Timer控 ...
- mybatis之关联关系映射
Mybatis关联关系映射 1.一对多 首先先用逆向生成工具生成t_hibernate_order.t_hibernate_order_item 这两张表对应的model与mapper OrderVo ...
- 数据库Count 语句详解
数据库查询相信很多人都不陌生,所有经常有人调侃程序员就是CRUD专员,这所谓的CRUD指的就是数据库的增删改查.在数据库的增删改查操作中,使用最频繁的就是查询操作.而在所有查询操作中,统计数量操作更是 ...
- window的pid为4的system进程占用80端口的解决办法
1.taskkill /pid 4 /f 无法终止进程占用80端口的进程时,运行 net stop http(若是第一次运行不能终止所有服务,继续运行该命令)
- C++ error C2015: too many characters in constant
错误原因:字符常量中的字符太多了. 错误分析: 单引号表示字符型常量. 一般的,单引号中必须有,也只能有一个字符(使用转义符时,转义符所表示的字符当作一个字符看待),如果单引号中的字符数多于4个,就会 ...
- javascript之大文件分段上传、断点续传
这里只写后端的代码,基本的思想就是,前端将文件分片,然后每次访问上传接口的时候,向后端传入参数:当前为第几块文件,和分片总数 下面直接贴代码吧,一些难懂的我大部分都加上注释了: 上传文件实体类: 看得 ...
- 2017.10.2 国庆清北 D2T2 树上抢男主
/* 我只看懂了求LCA */ #include<iostream> #include<cstring> #include<cstdio> #include< ...
- AtCoder Grand Contest 016题解
传送门 \(A\) 直接枚举最终的字母然后模拟就行了-- 就这数据范围还是别学我写的这种做法了-- const int N=105; char s[N];int las[26],mx[26],n,re ...