执行脚本 提示 command not found
问题现象:
初学shell,写了个脚本,
1.从windows 写好 脚本,然后部署到 linux 上。
2.chmod +x之后执行提示command not found,系统环境redhat9,用echo $SHELL检查shell版本显示为/bin/bash,为了排错,写了一个最简单的文件testfile,内容如下:
#!/bin/bash
echo "hello linux shell"
执行chmod +x testfile,运行,错误如前。
请各位大大指点
解决方法:
dos2unix test.sh
#############
命令简介:
dos2unix是将Windows格式文件转换为Unix、Linux格式的实用命令。Windows格式文件的换行符为\r\n ,而Unix&Linux文件的换行符为\n. dos2unix命令其实就是将文件中的\r\n 转换为\n。
而unix2dos则是和dos2unix互为孪生的一个命令,它是将Linux&Unix格式文件转换为Windows格式文件的命令。
命令语法:
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...]
unix2dos [options] [-c convmode] [-o file ...] [-n infile outfile ...]
命令参数:
此命令参数是Red Hat Enterprise Linux Server release 5.7下dos2unix命令参数,不同版本Linux的dos2nnix命令参数有可能不同。
|
参数 |
长参数 |
描叙 |
|
-h |
显示命令dos2unix联机帮助信息。 |
|
|
-k |
保持文件时间戳不变 |
|
|
-q |
静默模式,不输出转换结果信息等 |
|
|
-V |
显示命令版本信息 |
|
|
-c |
转换模式 |
|
|
-o |
在源文件转换,默认参数 |
|
|
-n |
保留原本的旧档,将转换后的内容输出到新档案.默认都会直接在原来的文件上修改, |
使用示例:
1: 查看dos2unix命令的帮助信息
[root@DB-Server myscript]# man dos2unix
[root@DB-Server myscript]# dos2unix -h
dos2unix Copyright (c) 1994-1995 Benjamin Lin
Copyright (c) 1998 Bernd Johannes Wuebben (Version 3.0)
Copyright (c) 1998 Christian Wurll (Version 3.1)
Usage: dos2unix [-hkqV] [-c convmode] [-o file ...] [-n infile outfile ...]
-h --help give this help
-k --keepdate keep output file date
-q --quiet quiet mode, suppress all warnings
always on in stdin->stdout mode
-V --version display version number
-c --convmode conversion mode
convmode ASCII, 7bit, ISO, Mac, default to ASCII
-l --newline add additional newline in all but Mac convmode
-o --oldfile write to old file
file ... files to convert in old file mode
-n --newfile write to new file
infile original file in new file mode
outfile output file in new file mode
2: dos2unix filename 将Windows格式文本转换为Unix&Linux格式文件
1: [root@DB-Server myscript]# cat -v test.sh
2: . /home/oracle/.bash_profile^M
3: echo ' '^M
4: date^M
5: echo ' '^M
6: ^M
7: sqlplus test/test @/home/oracle/scripts/test.sql^M
8: ^M
9: echo ' '^M
10: date^M
11: echo ' '^M
12: [root@DB-Server myscript]# dos2unix test.sh
13: dos2unix: converting file test.sh to UNIX format ...
14: [root@DB-Server myscript]# cat -v test.sh
15: . /home/oracle/.bash_profile
16: echo ' '
17: date
18: echo ' '
19:
20: sqlplus test/test @/home/oracle/scripts/test.sql
21:
22: echo ' '
23: date
24: echo ' '
3: dos2unix 可以一次转换多个文件
1: dos2unix filename1 filename2 filename3
1.https://www.cnblogs.com/kerrycode/archive/2015/12/26/5077969.html
2.http://bbs.chinaunix.net/thread-681229-1-1.html
执行脚本 提示 command not found的更多相关文章
- 使用sudo执行命令提示command not found
笔记: 使用源码部署nginx的时候,使用sudo nginx提示command not found,但是直接使用nginx会导致权限问题: 这种情况应该是环境变量导致的,使用 env |grep P ...
- ansible 远程执行时提示 command not found 问题
问题 最近在学习 ansible ,在使用普通用户远程执行 ip a 命令是发现提示错误:/bin/sh: ip: command not found. 原因 command not found 命令 ...
- windows 上jenkins slave 执行脚本提示成功,但是没有运行
控制台结果,但是脚本没有运行Started by user admin Building remotely on test_1110 in workspace D:\jenkins\workspace ...
- SSH非交互式密码授权远程执行脚本
公司有上百台服务器,需要为每台服务器都执行一个脚本,因为所有服务器的账号密码都是一样的,所以可以不用搭建ansible等自动化运维工具,我们直接通过SSH远程执行即可完成. 本文以三台服务器为例,系统 ...
- ssh执行远程服务器脚本 提示php: command not found
ssh执行远程服务器脚本 提示php: command not found 设置环境变量 一台机器作为管理机,来管理其他服务器,并通过key认证,免密码登陆的. 在管理机上通过ssh登陆到其他服务器来 ...
- Azkaban实战,Command类型单一job示例,任务中执行外部shell脚本,Command类型多job工作flow,HDFS操作任务,MapReduce任务,HIVE任务
本文转载自:https://blog.csdn.net/tototuzuoquan/article/details/73251616 1.Azkaban实战 Azkaba内置的任务类型支持comman ...
- shell脚本执行错误 $'\r':command not found
shell脚本执行错误 $'\r':command not found Linux下有命令dos2unix 可以用一下命令测试 vi -b filename 我们只要输入dos2unix *.sh就可 ...
- 将window的shell脚本通过ftp传输到Linux服务器后, shell脚本中执行时提示“没有那个文件或目录”的解决办法
出现bad interpreter:No such file or directory的原因,是文件格式的问题.这个文件是在Windows下编写的.换行的方式与Unix不一样,但是在vim下面如果不S ...
- sudo执行提示Command not found
运行一命令在普通用户下可行,切换到root用户依然可行,但在普通用户下使用sudo执行时,提示Command not found. 修改/etc/sudoers文件,找到类似下面的一行: Defaul ...
随机推荐
- c语言之秒数算法
// 水仙花树:是指一个3位数字,立方和 等于该数本身 // 秒数算法:随便输入一个大于0的数,求出对应的多少小时多少分钟多少秒 #include <stdio.h> / int main ...
- 渲染树render tree
CSSOM树和DOM树连接在一起形成一个render tree,渲染树用来计算可见元素的布局并且作为将像素渲染到屏幕上的过程的输入. DOM树和CSSOM树连接在一起形成render tree . r ...
- LaTeX常用的符号
推荐新手使用的网站:http://latex.codecogs.com/eqneditor/editor.php \(\sum _{d|n}{u(d)F(\frac{n}{d})}\) \sum _{ ...
- [poj2186]Popular Cows(targin缩点)
题意:求其他所有牛都认为其牛的牛的个数. 解题关键:targin算法模板题,缩点形成一棵树,并不一定是棵树,可能含有多个入度为0的点,寻找出度为0的点(缩点之后的点)的个数,如果个数大于0,则无解,否 ...
- HDU-2553
N皇后问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- JAVA中的BIO,NIO,AIO
在了解BIO,NIO,AIO之前先了解一下IO的几个概念: 1.同步 用户进程触发IO操作并等待或者轮询的去查看IO操作是否就绪, 例如自己亲自出马持银行卡到银行取钱 2.异步 用户触发IO操作以后, ...
- Flutter实战视频-移动电商-11.首页_屏幕适配方案讲解
11.首页_屏幕适配方案讲解 国人写的屏幕适配插件: https://github.com/OpenFlutter/flutter_screenutil 最新版本是0.5.1 在pubspec.yam ...
- 原生JS操作 table object HTMLTableSectionElement 对象,获取行数
<tbody id="infoTab"> <tr class="fomat"> <td class="blank&quo ...
- E20190409-hm
viable adj. 切实可行的; 能养活的; 能自行生产发育的; 有望实现的; resolution n. 分辨率; 解决; 决心; 坚决; produce vt. 产生; 生产; 制作; 创 ...
- E20190226-hm
shallow adj. 浅的,肤浅的; 表面的,皮毛的; (水,器物等) 浅的; (呼吸) 浅的; n. 浅处; 浅滩;