LINUX下奇异的脚本重编写,解决脚本无法执行
***********************************************声明**********************************************
原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明出处,否则追究版权法律责任。
表述有错误之处,请您留言或邮件([email protected])指明,不胜感激。
本文转载必须保留此处:http://blog.csdn.net/huangyanlong/article/details/39357927
深蓝的blog:http://blog.csdn.net/huangyanlong
***************************************************************************************************
今天,在安装oracle数据库的过程中,在执行安装包脚本时,报出比较奇怪的错误现象,如下所示:
[root@hyl test]# sh rpm.sh --单词释义 --ambiguous:模糊不清的 --redirect:直接的 : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : command not found : command not found : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : ambiguous redirect : command not found : command not found : command not found
于是,查看了执行的脚本,此脚本是在WIN平台下提前编写好的执行安装包的指令,如下所示:
[root@hyl test]# cat rpm.sh --查看有问题的脚本,没有发现异常编写 rpm -ivh binutils-2.17.50.0.6-14.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh binutils-devel-2.17.50.0.6-14.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh binutils-devel-2.17.50.0.6-14.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh compat-db-4.2.52-5.1.i386.rpm >> rpm.log 2>&1 rpm -ivh compat-db-4.2.52-5.1.x86_64.rpm >> rpm.log 2>&1 rpm -ivh control-center-2.16.0-16.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh control-center-2.16.0-16.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh control-center-devel-2.16.0-16.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh control-center-devel-2.16.0-16.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh gcc-4.1.2-50.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh gcc-c++-4.1.2-50.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-2.5-58.i686.rpm >> rpm.log 2>&1 rpm -ivh glibc-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-common-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-devel-2.5-58.i386.rpm >> rpm.log 2>&1 rpm -ivh glibc-devel-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-headers-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-utils-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libstdc++-devel-4.1.2-50.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libstdc++-devel-4.1.2-50.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libX11-1.0.3-11.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libX11-1.0.3-11.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libX11-devel-1.0.3-11.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libX11-devel-1.0.3-11.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libXp-1.0.0-8.1.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libXp-1.0.0-8.1.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libXp-devel-1.0.0-8.1.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libXp-devel-1.0.0-8.1.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libXpm-3.5.5-3.i386.rpm >> rpm.log 2>&1 rpm -ivh libXpm-3.5.5-3.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libXpm-devel-3.5.5-3.i386.rpm >> rpm.log 2>&1 rpm -ivh libXpm-devel-3.5.5-3.x86_64.rpm >> rpm.log 2>&1 rpm -ivh make-3.81-3.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh pdksh-5.2.14-36.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh sysstat-7.0.2-3.el5_5.1.x86_64.rpm >> rpm.log 2>&1 rm -rf binutils-2.17.50.0.6-14.el5.x86_64.rpm rm -rf binutils-devel-2.17.50.0.6-14.el5.i386.rpm rm -rf binutils-devel-2.17.50.0.6-14.el5.x86_64.rpm rm -rf compat-db-4.2.52-5.1.i386.rpm rm -rf compat-db-4.2.52-5.1.x86_64.rpm rm -rf control-center-2.16.0-16.el5.i386.rpm rm -rf control-center-2.16.0-16.el5.x86_64.rpm rm -rf control-center-devel-2.16.0-16.el5.i386.rpm rm -rf control-center-devel-2.16.0-16.el5.x86_64.rpm rm -rf gcc-4.1.2-50.el5.x86_64.rpm rm -rf gcc-c++-4.1.2-50.el5.x86_64.rpm rm -rf glibc-2.5-58.i686.rpm rm -rf glibc-2.5-58.x86_64.rpm rm -rf glibc-common-2.5-58.x86_64.rpm rm -rf glibc-devel-2.5-58.i386.rpm rm -rf glibc-devel-2.5-58.x86_64.rpm rm -rf glibc-headers-2.5-58.x86_64.rpm rm -rf glibc-utils-2.5-58.x86_64.rpm rm -rf libstdc++-devel-4.1.2-50.el5.i386.rpm rm -rf libstdc++-devel-4.1.2-50.el5.x86_64.rpm rm -rf libX11-1.0.3-11.el5.i386.rpm rm -rf libX11-1.0.3-11.el5.x86_64.rpm rm -rf libX11-devel-1.0.3-11.el5.i386.rpm rm -rf libX11-devel-1.0.3-11.el5.x86_64.rpm rm -rf libXp-1.0.0-8.1.el5.i386.rpm rm -rf libXp-1.0.0-8.1.el5.x86_64.rpm rm -rf libXp-devel-1.0.0-8.1.el5.i386.rpm rm -rf libXp-devel-1.0.0-8.1.el5.x86_64.rpm rm -rf libXpm-3.5.5-3.i386.rpm rm -rf libXpm-3.5.5-3.x86_64.rpm rm -rf libXpm-devel-3.5.5-3.i386.rpm rm -rf libXpm-devel-3.5.5-3.x86_64.rpm rm -rf make-3.81-3.el5.x86_64.rpm rm -rf pdksh-5.2.14-36.el5.x86_64.rpm rm -rf sysstat-7.0.2-3.el5_5.1.x86_64.rpm rpm -qa|grep binutils >> queryrpm.log 2>&1 rpm -qa|grep compat >> queryrpm.log 2>&1 rpm -qa|grep control >> queryrpm.log 2>&1 rpm -qa|grep gcc >> queryrpm.log 2>&1 rpm -qa|grep glibc >> queryrpm.log 2>&1 rpm -qa|grep gnome >> queryrpm.log 2>&1 rpm -qa|grep libstdc++ >> queryrpm.log 2>&1 rpm -qa|grep make >> queryrpm.log 2>&1 rpm -qa|grep pdksh >> queryrpm.log 2>&1 rpm -qa|grep sysstat >> queryrpm.log 2>&1
接下来采取的方法是,把该脚本中的内容在LINUX平台下重新拷贝到新建的文件中,如下所示:
[root@hyl test]# cat hyll.sh --LINUX系统下,把rpm.sh中的指令复制了一遍到新的脚本文件hyll.sh中 --重新执行脚本内容如下,与之前rpm.sh脚本内容完全一样 rpm -ivh binutils-2.17.50.0.6-14.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh binutils-devel-2.17.50.0.6-14.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh binutils-devel-2.17.50.0.6-14.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh compat-db-4.2.52-5.1.i386.rpm >> rpm.log 2>&1 rpm -ivh compat-db-4.2.52-5.1.x86_64.rpm >> rpm.log 2>&1 rpm -ivh control-center-2.16.0-16.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh control-center-2.16.0-16.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh control-center-devel-2.16.0-16.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh control-center-devel-2.16.0-16.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh gcc-4.1.2-50.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh gcc-c++-4.1.2-50.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-2.5-58.i686.rpm >> rpm.log 2>&1 rpm -ivh glibc-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-common-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-devel-2.5-58.i386.rpm >> rpm.log 2>&1 rpm -ivh glibc-devel-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-headers-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh glibc-utils-2.5-58.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libstdc++-devel-4.1.2-50.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libstdc++-devel-4.1.2-50.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libX11-1.0.3-11.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libX11-1.0.3-11.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libX11-devel-1.0.3-11.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libX11-devel-1.0.3-11.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libXp-1.0.0-8.1.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libXp-1.0.0-8.1.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libXp-devel-1.0.0-8.1.el5.i386.rpm >> rpm.log 2>&1 rpm -ivh libXp-devel-1.0.0-8.1.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libXpm-3.5.5-3.i386.rpm >> rpm.log 2>&1 rpm -ivh libXpm-3.5.5-3.x86_64.rpm >> rpm.log 2>&1 rpm -ivh libXpm-devel-3.5.5-3.i386.rpm >> rpm.log 2>&1 rpm -ivh libXpm-devel-3.5.5-3.x86_64.rpm >> rpm.log 2>&1 rpm -ivh make-3.81-3.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh pdksh-5.2.14-36.el5.x86_64.rpm >> rpm.log 2>&1 rpm -ivh sysstat-7.0.2-3.el5_5.1.x86_64.rpm >> rpm.log 2>&1 rm -rf binutils-2.17.50.0.6-14.el5.x86_64.rpm rm -rf binutils-devel-2.17.50.0.6-14.el5.i386.rpm rm -rf binutils-devel-2.17.50.0.6-14.el5.x86_64.rpm rm -rf compat-db-4.2.52-5.1.i386.rpm rm -rf compat-db-4.2.52-5.1.x86_64.rpm rm -rf control-center-2.16.0-16.el5.i386.rpm rm -rf control-center-2.16.0-16.el5.x86_64.rpm rm -rf control-center-devel-2.16.0-16.el5.i386.rpm rm -rf control-center-devel-2.16.0-16.el5.x86_64.rpm rm -rf gcc-4.1.2-50.el5.x86_64.rpm rm -rf gcc-c++-4.1.2-50.el5.x86_64.rpm rm -rf glibc-2.5-58.i686.rpm rm -rf glibc-2.5-58.x86_64.rpm rm -rf glibc-common-2.5-58.x86_64.rpm rm -rf glibc-devel-2.5-58.i386.rpm rm -rf glibc-devel-2.5-58.x86_64.rpm rm -rf glibc-headers-2.5-58.x86_64.rpm rm -rf glibc-utils-2.5-58.x86_64.rpm rm -rf libstdc++-devel-4.1.2-50.el5.i386.rpm rm -rf libstdc++-devel-4.1.2-50.el5.x86_64.rpm rm -rf libX11-1.0.3-11.el5.i386.rpm rm -rf libX11-1.0.3-11.el5.x86_64.rpm rm -rf libX11-devel-1.0.3-11.el5.i386.rpm rm -rf libX11-devel-1.0.3-11.el5.x86_64.rpm rm -rf libXp-1.0.0-8.1.el5.i386.rpm rm -rf libXp-1.0.0-8.1.el5.x86_64.rpm rm -rf libXp-devel-1.0.0-8.1.el5.i386.rpm rm -rf libXp-devel-1.0.0-8.1.el5.x86_64.rpm rm -rf libXpm-3.5.5-3.i386.rpm rm -rf libXpm-3.5.5-3.x86_64.rpm rm -rf libXpm-devel-3.5.5-3.i386.rpm rm -rf libXpm-devel-3.5.5-3.x86_64.rpm rm -rf make-3.81-3.el5.x86_64.rpm rm -rf pdksh-5.2.14-36.el5.x86_64.rpm rm -rf sysstat-7.0.2-3.el5_5.1.x86_64.rpm rpm -qa|grep binutils >> queryrpm.log 2>&1 rpm -qa|grep compat >> queryrpm.log 2>&1 rpm -qa|grep control >> queryrpm.log 2>&1 rpm -qa|grep gcc >> queryrpm.log 2>&1 rpm -qa|grep glibc >> queryrpm.log 2>&1 rpm -qa|grep gnome >> queryrpm.log 2>&1 rpm -qa|grep libstdc++ >> queryrpm.log 2>&1 rpm -qa|grep make >> queryrpm.log 2>&1 rpm -qa|grep pdksh >> queryrpm.log 2>&1 rpm -qa|grep sysstat >> queryrpm.log 2>&1 [root@hyl test]# sh hyll.sh
成功执行,对比前后两个脚本,书写内容上没有差异。
查看脚本权限,完全一样的两个脚本,hyll.sh可以正常执行,而rpm.sh却不能正常执行。
[root@hyl test]# ls -ll total 24 -rw-r--r-- 1 root root 3855 Sep 17 15:23 hyll.sh -rw-r--r-- 1 1 root root 3942 Sep 17 14:32 rpm.sh
小结:
今天遇到的问题感觉有点奇葩,几乎相同的两个脚本,一个可以执行,一个却不可以执行。后期又实验了一次,将脚本完全一样的复制了一次(脚本名称、内容),没做任何修改,就是把脚本重建了一次。重建后的脚本却可以执行了。想了下,唯一的区别就是无法执行的脚本实在WINDOWS上编写的,新的脚本实在LINUX上编写的。问题虽然解决,这个现象还是感觉非常奇怪。
于是带着好奇,在网上搜了下“ambiguous redirect”的报错原因,发现很多有关于重定向符格式的问题。于是想了下,是否是重定向符号是需要在LINUX下编写才会正常执行(也就是说LINUX系统对某些特殊操作符比较敏感)。
带着疑问,开始重新一次实验。大致思路如下:
在LINUX下将不可执行脚本修改为可执行的脚本(就是在LINUX下重写贴一遍指令),导出到WINDOWS下,重新换LINUX平台,将导出的脚本文件重命名,上传到实验平台,验证脚本的可用性。经过验证后发现,通过LINUX平台编辑的脚本均可以正常执行,脚本无法执行是由于跨平台书写格式所导致的。在WINDOWS和LINUX系统下其中对换行等格式都是有细微差别的,因此,今天这个报错告诉我们,今后修改脚本要在LINUX系统下完成,完成后再导入到自己的存储设备中,以防万一。
***********************************************声明**********************************************
原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明出处,否则追究版权法律责任。
表述有错误之处,请您留言或邮件([email protected])指明,不胜感激。
本文转载必须保留此处:http://blog.csdn.net/huangyanlong/article/details/39357927
深蓝的blog:http://blog.csdn.net/huangyanlong
***************************************************************************************************
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。