0

I have a problem with executing a command in Spring Shell. I'm using this code to blink my LED on a Raspberry PI but I'm getting a response error in the Tomcat's log.

JLineShellComponent shell;
Bootstrap bootstrap = new Bootstrap();      
shell = bootstrap.getJLineShellComponent();
shell.executeCommand("gpio -g write 17 1");
shell.stop();

The log output is:

org.springframework.shell.core.SimpleParser commandNotFound
WARNING: Command 'sudo gpio -g write 17 1' not found (for assistance press TAB)

When I'm using the echo command the problem persists.

kryger
  • 12,906
  • 8
  • 44
  • 65

1 Answers1

1

If you want to execute an OS Command via Spring Shell you have to prepend an exclamation mark.

shell.executeCommand("! gpio -g write 17 1");

A better solution is to use no Spring Shell at all

Runtime.getRuntime().exec("gpio -g write 17 1");
Jonas
  • 159
  • 8