如何在java中使用Cygwin运行shell脚本
从很久以来,我一直在努力与这个程序。我有一个shell脚本接受参数作为版本号和文件的路径。
From a long time i am struggling for with this program. I am having a shell script which accepts parameters as version number and path for the files. then that script creates Zip file with the name of version number congaing all file files to the folder.
我已经安装Cygwin到以下路径 D:/ cygwin
I have installed Cygwin on following path D:/cygwin. I am coping required files to same location where cygwin is installed D:\cygwin\bin
命令
D:/ cygwin / bin / bash -c'/bin/test/app.sh 04.10 D:\cygwin\bin\ Test_files
D:/cygwin/bin/bash -c '/bin/test/app.sh 04.10 D:\cygwin\bin\ Test_files
或者任何人都可以建议如何使用Cygwin在java中运行shell脚本。
Or Can any one please suggest how to run shell script in java using Cygwin.
重写问题: -
当我试图在命令提示符下运行以下命令时会出现错误
When i am trying to run following Command in command prompt it gives error
sh app.sh AK-RD 02.20 D:\cygwin\bin\Test_files
错误:-C:\Documents和Settings \\ \\sh app.sh AK-RD 02.20 D:\cygwin\bin\Test_files
Error:-C:\Documents and Settings\sh app.sh AK-RD 02.20 D:\cygwin\bin\Test_files
/usr/bin/app.sh:第51行:lib / lib .sh:没有这样的文件或目录
/usr/bin/app.sh: line 51: lib/lib.sh: No such file or directory
但是如果我在
D:cygwin\\ \\ bin \Test> sh app.sh AK-RD 02.20 D:\cygwin\bin\Test_files
D:cygwin\bin\Test>sh app.sh AK-RD 02.20 D:\cygwin\bin\Test_files
它可以正常工作。任何一个建议我如何避免这种错误。
It works fine. Can any one suggest me how to avoid this kind of errors.
Runtime run = Runtime.getRuntime();
Process p = run.exec("D:/cygwin/bin/bash -c \'/bin/test/app.sh 04.10 D:\cygwin\bin\ Test_files");
p.waitFor();