Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Duplicate
-
None
-
None
-
None
Description
one of our users (matt__) spent all day on freenode#solr trying to figure out why a simple script he had that called bin/post would work fine when he ran it, but didn't seem to do anything when run as a cronjob.
After helping him setup better logging from cron, it ultimiately came down to the fact that a command like this (which was the very first thing in his script)...
bin/post -c yyy -host xxx -d '<delete><query>zzz</query></delete>'
...was failing with an error like this...
Unrecognized argument: <delete><query>zzz</query></delete> If this was intended to be a data file, it does not exist relative to /opt/blah/blah
Ultimately we determined that the problem was how bin/post tests for "stdin" – by checking to see if it's not being run in a terminal (with ' ! -t 0 ') – in which case it doesn't treat the argument after -d as data, and instead lets it fall through to the next iteration of the arg parsing loop (as either another switch, or a filename)
the problem here being that running (in a script) as a cronjob is another case where bin/post is "not being run in a terminal" so the -d parsing would up completely ignoring the <delete>... string, evne though there was nothing being redirected on stdin.
the workaround is to use echo to give bin/post some stdin, since it was going to expect it for any usage of -d...
echo '<delete><query>zzz</query></delete>' | bin/post -c yyy -host xxx -d
Attachments
Issue Links
- is duplicated by
-
SOLR-13422 bin/post command not working when run from crontab
- Resolved