ProcessBuilder pb=new ProcessBuilder("./mybash.sh");
pb.directory(new File("/home/pera/"));
pb.redirectErrorStream(true);
Process p = pb.start();bash文件:cd ~/OpenFOAM/pera-2.2.0/run/cavity
blockMesh
出现:
./mybash.sh: ./mybash.sh: blockMesh: not found
错误.bash文件如果调用ls, ifconfig 等命令,一切正常。
而且blockMesh这个命令在终端下执行,也没问题。求解!!!!!

解决方案 »

  1.   

    如果.sh 命令没有错的,很有可能是在windows下编写,在移到到linux中出现问题。
    文件中有些隐藏的格式。
    建议在linux下写.sh文件或是用工具将其转换为linux下的格式。
      

  2.   

    .
    我的sh文件完全是在linux环境下编写的,跟windows没有关系
      

  3.   

    ou need to run this from an OpenFOAM aware terminal. Either start CAELinux-> OpenFoam Terminal or open a standard terminal and source the OpenFoam environment:source /opt/.bashrc-OpenFOAMor if you have a custom install: source /opt/openfoam201/etc/bashrc
      

  4.   

    sudo apt-cache search blockMesh
    搜索下,
    sudo apt-get install 结果
    安装一个吧