• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Event unix command - do I need special characters quoted

    How-To
    4
    10
    4.8k
    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.
    • F
      fclauson
      last edited by

      I have an event command which works if submitted direct to the command line but comes up with an error when run as an triggered event

      find /usr/local/tomcat/logs/ -type f -name "*" -mtime +5 -exec rm -f "{}" ;

      WARN 2010-09-13 00:00:00 (com.serotonin.mango.rt.maint.work.ProcessWorkItem.execute:85) - Process error: 'find: missing argument to '-exec'
      '

      note the additional single inverted comma on the second line.

      Have I missed any quoting on my unix command

      1 Reply Last reply Reply Quote 0
      • S
        SteveE
        last edited by

        I believe that apostrophe on the second line matches the one on the first line before the word "find":

        ...Process error: 'find: missing argument to '-exec'
        ^
        What does the contents of the directory look like (ls or ls -l)?

        1 Reply Last reply Reply Quote 0
        • F
          fclauson
          last edited by

          Steve - thanks - this is what I have

          francis@automaiton1:~$ ls /usr/local/tomcat/logs/
          catalina.2010-09-11.log catalina.out.8 mango.log2010-09-05
          catalina.2010-09-12.log catalina.out.9 mango.log2010-09-06
          catalina.out host-manager.2010-09-11.log mango.log2010-09-07
          catalina.out.1 host-manager.2010-09-12.log mango.log2010-09-08
          catalina.out.2 localhost.2010-09-11.log mango.log2010-09-09
          catalina.out.3 localhost.2010-09-12.log mango.log2010-09-10
          catalina.out.4 localhost.2010-09-13.log mango.log2010-09-11
          catalina.out.5 manager.2010-09-11.log mango.log2010-09-12
          catalina.out.6 manager.2010-09-12.log
          catalina.out.7 mango.log

          1 Reply Last reply Reply Quote 0
          • S
            SteveE
            last edited by

            I don't see any unusually-named files in that listing, which was my first guess. I can reproduce the error message by embedding a carriage return in the command immediately before the ;. For example:

            $ find . -type "*" -exec ls -l "{}"^M;
            find: missing argument to '-exec'

            (I inserted the ^M by typing ctrl-V<CR>.) So my next guess is that you have a hidden carriage return or non-printable character in the command itself.

            1 Reply Last reply Reply Quote 0
            • M
              mlohbihler
              last edited by

              No idea whether this will work, but maybe try a "\" instead of ""?

              Best regards,
              Matthew

              1 Reply Last reply Reply Quote 0
              • F
                fclauson
                last edited by

                Nope - none of the above worked

                Need to have a further play - convinced its a quoting type problem - but if any one can get it to work please let me know

                Francis

                1 Reply Last reply Reply Quote 0
                • M
                  mlohbihler
                  last edited by

                  This works for me:

                  find /usr/local/tomcat/logs/ -type f -name * -mtime +5 -exec rm -f {} ;
                  

                  I.e. take out the dquotes and the ''.

                  Best regards,
                  Matthew

                  1 Reply Last reply Reply Quote 0
                  • JoelHaggarJ
                    JoelHaggar
                    last edited by

                    Try removing /usr/local/tomcat/.

                    In my experience when Mango runs a command line it does it as the tomcat user which it's home directory is tomcat so I think it would work as this

                    find logs/ -type f -name * -mtime +5 -exec rm -f {} ;

                    I haven't tried it but it might help.

                    Joel.

                    1 Reply Last reply Reply Quote 0
                    • F
                      fclauson
                      last edited by

                      Hi all

                      I have found a work around - not sure why this works but it does

                      Mango runs as root and when I run the command

                      find /usr/local/tomcat/logs/ -type f -name * -mtime +5 -exec rm -f {} ;

                      I get the error mentioned

                      but when I run it as my user ("francis")

                      sudo -u francis find /usr/local/tomcat/logs/ -type f -name * -mtime +5 -exec rm -f {} ;

                      then this works

                      it must be something to do with privileges etc - but I do not know why

                      Francis

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post