我在Spring Shell中执行命令时遇到了问题。我使用此代码在Raspberry PI上闪烁我的LED,但我在Tomcat的日志中收到一个响应错误。
JLineShellComponent shell;
Bootstrap bootstrap = new Bootstrap();
shell = bootstrap.getJLineShellComponent();
shell.executeCommand("gpio -g write 17 1");
shell.stop();日志输出为:
org.springframework.shell.core.SimpleParser commandNotFound
WARNING: Command 'sudo gpio -g write 17 1' not found (for assistance press TAB)当我使用echo命令时,问题仍然存在。
发布于 2016-06-06 04:12:29
如果你想通过Spring Shell执行一个操作系统命令,你必须在前面加上一个感叹号。
shell.executeCommand("! gpio -g write 17 1");更好的解决方案是根本不使用Spring Shell
Runtime.getRuntime().exec("gpio -g write 17 1");https://stackoverflow.com/questions/35020591
复制相似问题