【发布时间】:2012-08-09 19:53:48
【问题描述】:
我要执行这个命令
D:/Projects/GDAL/ogr2ogr.exe -f "MapInfo File" D:/Projects/GDAL/r/output_test.tab PG:"host=localhost user=postgres password=123456 dbname=postgis" -sql "SELECT * from filedata WHERE num=1"
我试过这个:
Process process = Runtime.getRuntime().exec(new String[]{"cmd.exe", "D:/Projects/GDAL/ogr2ogr.exe -f \"MapInfo File\" D:/Projects/GDAL/r/output_test.tab PG:\"host=localhost user=postgres password=123456 dbname=postgis\" -sql \"SELECT * from filedata WHERE num=1\""});
我没有收到任何错误,但什么也没发生。 我的错在哪里?
【问题讨论】:
-
你不是真的在使用 DOS,是吗?
-
exec 已经执行命令了吧?需要调用cmd.exe吗?
-
我只想执行这个命令。
-
您的引号不正确...您不能使用单引号编写字符串文字+在字符串文字内必须像这样转义双引号
\"...还可以看看@ 987654321@ ...更方便 -
对不起,我提出了另一个 cde 行有问题。现在是正确的。但是
\"没有帮助。