TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Echo linux command not working when run from the internet, but works on device

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 1.1k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jackson pollard
      last edited by

      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.

      RussR 1 Reply Last reply Reply Quote 0
      • RussR Offline
        Russ @jackson pollard
        last edited by Russ

        @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.

        Russell VanderMey

        J 1 Reply Last reply Reply Quote 0
        • J Offline
          jackson pollard @Russ
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post