Event unix command - do I need special characters quoted
-
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
-
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)? -
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 -
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.
-
No idea whether this will work, but maybe try a "\" instead of ""?
-
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
-
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 ''.
-
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.
-
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