-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug report: process cmd error on Linux #2
Comments
thank you,I fixed this problem in the official version. |
hey bro, thx your quick fix,but its still has some problems. if (isWindowsOS) {
//windows下的命令
cmd = new String[]{"cmd.exe", "/c", "dot", "-Tpng", dotPath[i], "-o", imgPath};
} else {
//linux下的命令
// imgPath = ConstatField.ASTResultTemp + ConstatField.separator + dotPath[i].substring(dotPath[i].lastIndexOf("\\") + 1, dotPath[i].lastIndexOf(".")) + ".png";
// fixme:for example path ,change yourself, the imgPath in unix will be like:
// $home/proj/tools/datas/result/ast/1225819235468336//$home/proj/tools/datas/ast/1225819235466361/1225833393958640.png
// has tow slash in imgPath
imgPath = ConstatField.ASTResultTemp + ConstatField.separator + dotPath[i].lastIndexOf(".") + ".png";
//fixme: use `/usr/bash -c` may has problem in some shell like zsh
cmd = new String[]{"dot", "-Tpng" , dotPath[i] , "-o", imgPath};
}
try {
logger.info("开始生成图片 " + dotPath[i]);
logger.info("正在执行命令 "+ Arrays.toString(cmd));
sleep(1000);
String charsetName = isWindowsOS ? "GBK" : "UTF-8";
Runtime.getRuntime().exec(cmd);
// byte[] bytes = new Scanner(Runtime.getRuntime().exec(cmd).getInputStream(), charsetName).useDelimiter("\\A").next().getBytes(charsetName);
byte[] bytes = null;
Scanner runCmd = new Scanner(Runtime.getRuntime().exec(cmd).getInputStream(), charsetName).useDelimiter("\\A");
//fixme: on linux : detect hasNext otherwise will throw a NoSuchElementException
if (runCmd.hasNext())
bytes = runCmd.next().getBytes(charsetName);
//... by the way the cfg module may same problems |
Thanks for the suggestion, this looks great, can you submit a pull request for this project?
|
Because my OS is Windows, I can't do the test well on Linux environment. If it is convenient for you, could you please submit a pr? |
ok , I'll submit a pr later :) |
Env
Log
Reason
SPATool/src/main/java/com/sumsec/core/ast/util/DotHandler.java
Line 44 in 2823aef
Like windows if branch , replace "+" to "," may fix the bug.
The text was updated successfully, but these errors were encountered: