Linux Shell 명령은 수동으로 입력 할 때 작동합니다. 스크립트 파일에 넣을 때 작동하지 않음

Nuka Raku

내 컴퓨터에 Oracle이 설치에 필요한 전제 조건이 있는지 확인하는 데 사용되는 LinuxCommands라는 Linux 스크립트가 있습니다. Windows 메모장에서 모든 텍스트를 복사하여 Linux 터미널에 붙여 넣으면 스크립트가 작동하지만 실제 .sh 파일을 Linux 터미널로 ftp하고 bash를 호출하여 실행하면 작동하지 않습니다. ./ 표기법을 사용하면 스크립트가 전혀 작동하지 않습니다. 명령을 복사하고 ./ 또는 bash 표기법을 사용하여 파일을 실행하기 위해 루트를 사용하고 있습니다. Linux 스크립트는 다음과 같습니다.

#!/bin/bash
#Install packages, upgrade those that already exist

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' binutils-2.17.50.0.6 compat-libstdc++-33-3.2.3 compat-libstdc++-33-3.2.3 elfutils-libelf-0.125 elfutils-libelf-devel-0.125 gcc-4.1.2 gcc-c++-4.1.2 glibc-2.5-24 glibc-common-2.5 glibc-devel-2.5 glibc-headers-2.5 ksh-20060214 libaio-0.3.106 libaio-devel-0.3.106 libgcc-4.1.2 libstdc++-4.1.2 libstdc++-devel make-3.81 sysstat-7.0.2|grep "install ok installed")
echo Checking for libraries: $PKG_OK
if [ "" == "$PKG_OK" ]; then
  echo "Not Installed. Installing"
  yum -y install binutils-2.17.50.0.6 compat-libstdc++-33-3.2.3 compat-libstdc++-33-3.2.3 elfutils-libelf-0.125 elfutils-libelf-devel-0.125 gcc-4.1.2 gcc-c++-4.1.2 glibc-2.5-24 glibc-common-2.5 glibc-devel-2.5 glibc-headers-2.5 ksh-20060214 libaio-0.3.106 libaio-devel-0.3.106 libgcc-4.1.2 libstdc++-4.1.2 libstdc++-devel make-3.81 sysstat-7.0.2
fi


#Adds oinstall and dba groups
/bin/id -g oinstall 2>/dev/null \
[ $? -eq 0 ] && echo "Group found" || sudo /usr/sbin/groupadd oinstall

/bin/id -g dba 2>/dev/null \
[ $? -eq 0 ] && echo "Group found" || sudo /usr/sbin/groupadd dba

#Adds oracle user in oinstall group

if id -u oracle >/dev/null 2>&1; then
        echo "user exists"
else
        /usr/sbin/useradd -m -g oinstall -G dba oracle
fi

#Creates installation directory for Oracle
chown -R oracle:oinstall /u00/Oracle12CInstall
chmod -R 775 /u00/Oracle12CInstall

#Adds Oracle variables to the Oracle User's profile.
cat <<EOF > /home/oracle/.bash_profile
ORACLE_BASE=/u00/Oracle12cInstall
ORACLE_HOME=$ORACLE_BASE/test2/product/121
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export ORACLE_BASE
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:/usr/X11R6/bin:/usr/lib

export PATH

export ORACLE_BASE ORACLE_HOME LD_LIBRARY_PATH
umask 022

EOF

Linux 터미널에서 실행할 때 발생하는 오류는

bash LinuxCommands
: command not found 3:
LinuxCommands: line 4: dpkg-query: command not found
Checking for libraries:
LinuxCommands: line 47: syntax error: unexpected end of file
Nuka Raku

이 질문은 다음을 실행하여 해결되었습니다.

dos2unix LinuxCommands

위의 명령은 내 파일에서 DOS 줄 끝을 제거했으며 성공적으로 실행할 수있었습니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관