Echo linux command not working when run from the internet, but works on device
-
Here's an example of one of the commands I want to run:
echo "python giveTour.py fullTour" > Desktop/Cram0002/reqs.txt
Basically just trying to echo a line into a file. It works when I activate the trigger directly on the laptop, but if I activate it using the triggerCMD website or Alexa, the command does nothing. Its not a connection issue either, because if I replace the above command with a different one, it runs correctly. It is only failing for commands that echo something into a file. I can't find any reason these would fail when the triggers work correctly when run on the machine.
Any help would be appreciated.
-
@jackson-pollard, I was able to reproduce the problem and I figured out why it worked in the GUI but not from the website.
This is how you can fix it. Just change your command to this:
echo "python giveTour.py fullTour" > ~/Desktop/Cram0002/reqs.txt
The reason it didn't work is the present working directory is /usr/lib/triggercmdagent/resources/app/src when the command runs remotely, but when you run it locally via the GUI, your present working directory is your home directory.
So if you just specify your home folder using the ~ character, it finds the correct folder to write the file to.
-
@russ Thanks a lot, this worked. I shouldn't've assumed it would always run in the home directory. This saved me a lot of headaches.