yum install 安装失败

问题1:今天运行oracle11g enabler的sh脚本时, 遇到error说can't run .../*.sh, 可经过check, 这些sh脚本明明已经被解压到指定path下了, 执行脚本的user和group也都实现创建好了, 没有问题。于是手动去运行一个sh试试, 终于发现了问题, 报错如下:

[oracle11g@sf-redhat-64-4 bin]$ ./startup.sh
bash: ./startup.sh: /bin/sh^M: bad interpreter: No such file or directory


原来是enabler是在windows上从git clone下来, 然后运行maven做成的zip, 结果在windows上用notepad打开过, 文本被转换成了windows格式。具体原因如下:

DOS-based text files use a pair of carriage return (CR) and line feed (LF) as a new-line delimiter. On the other hand, UNIX-based text files simply use LFs to terminate each line. In order to convert a text file from DOS format to UNIX format, you can use a command-line tool called dos2unix.

解决办法:可以去去 http://pkgs.org/centos-6-rhel-6/centos-rhel-x86_64/dos2unix-3.1-37.el6.x86_64.rpm.html上下载dos2unix, 运行dos2unix [FILES], 重新转换即可.

有时候在windows下编写的python脚本在linux下也不能运行,也是因为^M的原因,因为windows下行结束符是/r/n,而linux只需要/n. 我们可以使用cat –v来显示一个文本文件中的^M符号,或者如果有非improved的vi版本的话(注意是非improved版本, 否则也显示不出来),也可以直接vi查看。

除了以上用dos2unix工具, 还有个简单的办法替换掉文本中的^M,通常这类文件在vi或vim中下面都会显示dos模式,那么我们直接设置为unix模式就会自动清楚了。方法是:

1. :set fileformat=unix
2. 保存退出



问题2: 下了一个dos2unix的rpm安装包, 可安装时说没有public key

[root@sf-redhat-64-4 michael]# yum install dos2unix-3.1-37.el6.x86_64.rpm       Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Examining dos2unix-3.1-37.el6.x86_64.rpm: dos2unix-3.1-37.el6.x86_64
Marking dos2unix-3.1-37.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package dos2unix.x86_64 0:3.1-37.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package      Arch       Version          Repository                       Size
================================================================================
Installing:
dos2unix     x86_64     3.1-37.el6       /dos2unix-3.1-37.el6.x86_64      18 k

Transaction Summary
================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total size: 18 k
Installed size: 18 k
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY


Public key for dos2unix-3.1-37.el6.x86_64.rpm is not installed


解决办法:加上忽略参数 --nogpgcheck

[root@sf-redhat-64-4 michael]# yum install dos2unix-3.1-37.el6.x86_64.rpm --nogpgcheck
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Examining dos2unix-3.1-37.el6.x86_64.rpm: dos2unix-3.1-37.el6.x86_64
Marking dos2unix-3.1-37.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package dos2unix.x86_64 0:3.1-37.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package      Arch       Version          Repository                       Size
================================================================================
Installing:
dos2unix     x86_64     3.1-37.el6       /dos2unix-3.1-37.el6.x86_64      18 k

Transaction Summary
================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total size: 18 k
Installed size: 18 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : dos2unix-3.1-37.el6.x86_64                               1/1

Installed:
  dos2unix.x86_64 0:3.1-37.el6

Complete!

猜你喜欢

转载自mxy0521.iteye.com/blog/1920869