`
lee79
  • 浏览: 103287 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Java执行Shell脚本异常No such file or directory

阅读更多

最近在做一个项目时,遇到一个问题,用Runtime.getRuntime().exec()方法执行Linux的一个Shell脚本时,报

Cannot run program "./script/setip.sh": java.io.IOException: error=2, No such file or directory]
java.io.IOException: Cannot run program "./script/setip.sh": java.io.IOException: error=2, No such file or directory

 

最终发现是这个shell脚本本身有问题,字符是windows格式(主要是换行符导致),用 vi 打开这个shell脚本就可以看到每一行后面有 ^M 的字符,把这个文件转到 Linux 格式就可以了,方法如下:

 

[root@localhost script]# dos2unix -o seip.sh
dos2unix: converting file seip.sh to UNIX format ...

分享到:
评论

相关推荐

    hadoop hbase_shell操作命令

    hadoop hbase_shell操作命令hadoop hbase_shell操作命令hadoop hbase_shell操作命令hadoop hbase_shell操作命令hadoop hbase_shell操作命令hadoop hbase_shell操作命令

    带rtmp模块的nginx安装脚本

    centos7中安装带rtmp模块的nginx自动化脚本

    create_directory_struct:用于创建目录结构的Shell脚本

    create_directory_struct:用于创建目录结构的Shell脚本

    Shell脚本中多命令逻辑执行顺序的方法详解

    Linux中可以使用分号“;”、双and号“&&”和双竖线“||”来连接多个命令。单”&”符号也算命令连接符号,只不过它是将其前面的命令放入后台执行,所以可以...ls: cannot access das: No such file or directory hdakl

    windows下写的shell脚本在linux执行出错的解决办法

    在Windows下写了一个shell脚本,上传到Linux下执行时报错: 代码如下:[root@localhost test]# ./test.sh -bash: ./test.sh: /bin/sh^M: bad interpreter: No such file or directory test.sh源码: 代码如下:#!...

    shell脚本中执行时提示“没有那个文件或目录”的解决办法

    出现bad interpreter:No such file or directory的原因,是文件格式的问题。这个文件是在Windows下编写的。换行的方式与Unix不一样,但是在vim下面如果不Set一下又完全看不出来。问题分析:1、将windows 下编写好的...

    getcwd cannot access parent directories错误解决方法

    shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory 该错误表示 getcwd 命令无法定位到当前工作目录。一般来说是因为你 cd 到了某个目录之后 ...

    java反编译工具jad 1.5.8g(可以反编译jdk1.5,1.6)

    How to use Jad <br>To decompile a single JAVA class file 'example1.class' type the following: <br> jad example1.class <br>This command creates file 'example1.jad' in the current directory...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 登陆服务器时输入 公帐号 openlab-open123 telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss 老师测评网址 http://172.16.0.198:8080/poll/ 各个 ...

    Vxworks学习笔记

    个人前几年学习Vxworks时,整理的笔记,总给大家了。 1 基于硬盘启动的Vxworks环境搭建 3 2 Vxworks引导盘制作 6 2.1 通过DOS加载VxWorks方法 6 2.2 Bootrom三种类型 7 ...31 No such file or directory错误? 107

    ora分析脚本

    [-m min_size]: generate a graph from v and display it or store it in a file if the -o option is used. -s [] to diff with a previous snapshot (see pgasnap cmd) -o [graphfile] to store the result in ...

Global site tag (gtag.js) - Google Analytics