The strange script in LINUX is rewritten to solve the problem that the script cannot be executed.
**************************************** ******************************** **************
Original Works are from the blog of "Deep Blue blog". You are welcome to repost them. Please indicate the source when you repost them. Otherwise, the copyright will be held legally responsible.
Please leave a message or email (hyldba@163.com) indicating that there is an error. Thank you very much.
This document must be reprinted here:Http://blog.csdn.net/huangyanlong/article/details/39357927
Deep Blue blog:Http://blog.csdn.net/huangyanlong
**************************************** **************************************** *******************
Today, during the installation of the oracle database, a strange error occurs when the installation package script is executed, as shown below:
[Root @ hyl test] # sh rpm. sh -- word meaning -- ambiguous: ambiguous -- redirect: Direct: ambiguous redirect: Wrong redirect: ambiguous redirect: Too redirect: ambiguous redirect: ambiguous redirect: Too redirect: ambiguous redirect: command not found: ambiguous redirect: specified redirect: ambiguous redirect: command not found: command not found
Therefore, I checked the executed script, which is a command to execute the installation package in advance on the WIN platform, as shown below:
[Root @ hyl test] # cat rpm. sh -- View problematic script, no exception found to write 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> & amp; 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> & 1rm-rf binutils-2.17.50.0.6-14.el5.x86_64.rpmrm-rf binutils-devel-2.17.50.0.6-14.el5.i386.rpmrm-rf binutils-devel-2.17.50.0.6-14.el5.x86_64.rpmrm-rf compat-db-4.2.52-5.1.i386.rpmrm-rf compat-db-4.2.52-5.1.x86_64.rpmrm-rf control-center-2.16.0-16.el5.i386.rpmrm-rf control-center-2.16.0-16.el5.x86_64.rpmrm-rf control-center-devel-2.16.0-16.el5.i386.rpmrm-rf gcc-c ++-4.1.2-50. el5.x86 _ 64. rpmrm-rf glibc-2.5-58.i686.rpmrm-rf glibc-2.5-58.x86_64.rpmrm-rf glibc-common-2.5-58.x86_64.rpmrm-rf glibc-devel-2.5-58.i386.rpmrm-rf glibc-devel-2.5-58.x86_64.rpmrm-rf glibc-headers-2.5-58.x86_64.rpmrm-rf glibc-utils-2.5-58.x86_64.rpmrm-rf libstdc ++-devel-4.1.2-50.el5.i386.rpmrm-rf libstdc ++-devel-4.1.2-50.el5.x86_64.rpmrm-rf libX11-1.0.3-11.el5.i386.rpmrm- rf libX11-1.0.3-11.el5.x86_64.rpmrm-rf libX11-devel-1.0.3-11.el5.i386.rpmrm-rf libX11-devel-1.0.3-11.el5.x86_64.rpmrm-rf libXp-1.0.0-8.1.el5.i386.rpmrm-rf libXp-1.0.0-8.1.el5.x86_64.rpmrm-rf libXp-devel-1.0.0-8.1.el5.i386.rpmrm-rf libXp-devel-1.0.0-8.1.el5.x86_64.rpmrm-rf libXpm-3.5.5-3.i386.rpmrm-rf libXpm-3.5.5-3.x86_64.rpmrm-rf libXpm-devel-3.5.5-3.i386.rpmrm-rf libXpm-devel-3.5.5-3.x86_64.rpmrm-rf make-3.81-3.el5.x86_64.rpmrm sysstat-7.0.2-3.el5_5.1.x86_64.rpmrpm-qa | grep binutils> queryrpm. log 2> & amp; 1 rpm-qa | grep compat & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep control & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep gcc & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep glibc & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep gnome & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep libstdc ++ & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep make & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep pdksh & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep sysstat & gt; queryrpm. log 2> & 1
The next method is to copy the content in the script to the new file on the LINUX platform, as shown below:
[Root @ hyl test] # cat hyll. sh -- in LINUX, run the rpm command. the commands in sh are copied to the new script file hyll. sh -- Re-execute the script content as follows, with the previous rpm. sh script content exactly the same 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> & amp; 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> & 1rm-rf binutils-2.17.50.0.6-14.el5.x86_64.rpmrm-rf binutils-devel-2.17.50.0.6-14.el5.i386.rpmrm-rf binutils-devel-2.17.50.0.6-14.el5.x86_64.rpmrm-rf compat-db-4.2.52-5.1.i386.rpmrm-rf compat-db-4.2.52-5.1.x86_64.rpmrm-rf control-center-2.16.0-16.el5.i386.rpmrm-rf control-center-2.16.0-16.el5.x86_64.rpmrm-rf control-center-devel-2.16.0-16.el5.i386.rpmrm-rf gcc-c ++-4.1.2-50. el5.x86 _ 64. rpmrm-rf glibc-2.5-58.i686.rpmrm-rf glibc-2.5-58.x86_64.rpmrm-rf glibc-common-2.5-58.x86_64.rpmrm-rf glibc-devel-2.5-58.i386.rpmrm-rf glibc-devel-2.5-58.x86_64.rpmrm-rf glibc-headers-2.5-58.x86_64.rpmrm-rf glibc-utils-2.5-58.x86_64.rpmrm-rf libstdc ++-devel-4.1.2-50.el5.i386.rpmrm-rf libstdc ++-devel-4.1.2-50.el5.x86_64.rpmrm-rf libX11-1.0.3-11.el5.i386.rpmrm- rf libX11-1.0.3-11.el5.x86_64.rpmrm-rf libX11-devel-1.0.3-11.el5.i386.rpmrm-rf libX11-devel-1.0.3-11.el5.x86_64.rpmrm-rf libXp-1.0.0-8.1.el5.i386.rpmrm-rf libXp-1.0.0-8.1.el5.x86_64.rpmrm-rf libXp-devel-1.0.0-8.1.el5.i386.rpmrm-rf libXp-devel-1.0.0-8.1.el5.x86_64.rpmrm-rf libXpm-3.5.5-3.i386.rpmrm-rf libXpm-3.5.5-3.x86_64.rpmrm-rf libXpm-devel-3.5.5-3.i386.rpmrm-rf libXpm-devel-3.5.5-3.x86_64.rpmrm-rf make-3.81-3.el5.x86_64.rpmrm sysstat-7.0.2-3.el5_5.1.x86_64.rpmrpm-qa | grep binutils> queryrpm. log 2> & amp; 1 rpm-qa | grep compat & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep control & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep gcc & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep glibc & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep gnome & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep libstdc ++ & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep make & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep pdksh & gt; queryrpm. log 2> & amp; 1 rpm-qa | grep sysstat & gt; queryrpm. log 2> & 1 [root @ hyl test] # sh hyll. sh
The script is successfully executed. There is no difference in the content of the two scripts.
View the script permission. hyll. sh can be executed normally, but rpm. sh cannot be executed normally.
[root@hyl test]# ls -lltotal 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
Summary:
The problem we encountered today is a little strange. There are almost two identical scripts, one of which can be executed, but the other cannot. The experiment was conducted again later, and the script was completely copied once (The Script Name and content) without any modification, that is, the script was rebuilt once. The script after reconstruction can be executed. After thinking about it, the only difference is that the unexecutable script is actually written on WINDOWS, and the new script is actually written on LINUX. Although the problem is solved, this phenomenon is still very strange.
With curiosity, I searched the internet for the error cause of "ambiguous redirect" and found many problems with the redirection character format. So I thought about whether or not the redirection symbol should be written in LINUX for normal execution (that is, the LINUX system is sensitive to some special operators ).
Start a new experiment with questions. The general idea is as follows:
In LINUX, modify the unexecutable script to an executable script (that is, rewrite and paste the command again in LINUX), export it to WINDOWS, and change it to the LINUX platform, rename the exported script file and upload it to the experiment platform to verify the availability of the script. After verification, it is found that all scripts edited on the LINUX platform can be executed normally, and the script cannot be executed due to the cross-platform writing format. In WINDOWS and LINUX systems, the line breaks and other formats are all slightly different. Therefore, today's error tells us that the modification script will be completed in LINUX in the future, import the data to your storage device just in case.
**************************************** ******************************** **************
Original Works are from the blog of "Deep Blue blog". You are welcome to repost them. Please indicate the source when you repost them. Otherwise, the copyright will be held legally responsible.
Please leave a message or email (hyldba@163.com) indicating that there is an error. Thank you very much.
This document must be reprinted here:Http://blog.csdn.net/huangyanlong/article/details/39357927
Deep Blue blog:Http://blog.csdn.net/huangyanlong
**************************************** **************************************** *******************
The linux script cannot be executed. A simple script writing problem occurs.
Echo-e "I will use 'touch' command to cteate 3 files ."
Try this
Read-p "Please input the filename what you want:" fileuser
Filename = $ (fileuser:-"filename ")
Date1 = 'date -- date = '2 days ago '+ % Y % m % d'
Date2 = 'date -- date = '1 days ago '+ % Y % m % d'
Date3 = 'date + % Y % m % d'
File1 = "$ filename" "$ date1"
File2 = "$ filename" "$ date2"
File3 = "$ filename" "$ date3"
Touch $ file1
Touch $ file2
Touch $ file3
The difference is that date is followed by two-
How to Write a SHELL script in linux and execute these commands every day:
A crontab must be used for automatic execution every day.
The script can be written as follows:
#! /Bin/bash
PRO = ps x | grep p | grep-v grep | awk '{print $1 }'
Kill-9 $ PRO
Service httpd start
The script above implements
If you want to automatically execute each day, you need to add a crontab
If your P process is an apache process, you can start it directly. If not, restart is required.
0 1 ***/usr/local/encode/apachectl restart
The above mentioned script can only be executed under/usr/local/encode, which indicates that your service runs directly.