(Please cc to the list so others can help or learn.)<br><br><div class="gmail_quote"><div dir="ltr">On Fri, 1 Jul 2016, 01:47 Joshua Hunt <<a href="mailto:joshuasocrates@gmail.com">joshuasocrates@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"> Here is the error I receive when I run using $XYMONHOME/server/bin/xymongrep : <div><br></div><div>/server/bin/xymongrep: No such file or directory</div></div></blockquote></div><div><br></div><div>The environment variable XYMONHOME isn't set.  Such scripts are usually run within a xymon environment. For testing, it's easiest to setup the environment by running xymoncmd.  You can either run xymoncmd with no arguments and use it as an interactive shell (and then run your script like you have been), or you can give your script to xymoncmd as an argument.</div><div><br></div><div>Like:</div><div><br></div><div>$ xymoncmd /your/script</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:13px">However, I have gone ahead and put in a manual path without using Xymon built in variables, </span></div></div></blockquote></div><div><br></div><div>This is probably the cause of you're troubles.</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:13px">and that seems to work just fine.</span></div></div></blockquote></div><div><br></div><div>"Seems to", meaning with no error?</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:13px"> When I do that though, the majority of the script flat out doesn't run. </span></div></div></blockquote></div><div><br></div><div>If the output of xymongrep is empty (either an error, or no matching lines) then the while loop body won't execute even once.</div><div><br></div><div>Note that xymongrep uses some xymon environment variables to do what it needs to do, so of you're not running it via xymoncmd or xymonlaunch, it might not be able to get any output for your script to use. At the very least, xymongrep needs HOSTCFG to be set to the path of the hosts.cfg file, according to the xymongrep man page.</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:13px">Anything following "while read L" is skipped, so I'm assuming that my problem is ultimately lying in that line.</span></div></div></blockquote></div><div><br></div><div>Yes, or the input to that line via the pipe is the problem.</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>HOSTTAG="tagname"<br>COLUMN="${HOSTTAG}"<br>$XYMONHOME/server/bin/xymongrep "${HOSTTAG}" | while read L<br>do<br><br>     set "$L"<br><br>     HOSTIP="$1"<br>     MACHINEDOTS="$2"<br></div></div></blockquote></div><div><br></div><div>Try running this exact xymongrep command manually, after setting HOSTTAG and XYMONHOME, like:</div><div><br></div><div>$ HOSTTAG="tagname"</div><div>$ XYMONHOME=~xymon</div><div>$ <span style="font-size:13px">$XYMONHOME/server/bin/xymongrep "${HOSTTAG}"</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">I suspect you'll get no output because xymongrep can't do what it needs because environment.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Then do the same but within a xymoncmd shell.</span></div><div><span style="font-size:13px"><br></span></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>     MACHINE=$(echo $2 | $SED -e's/\./,/g')     # I am not sure what this line is for or what it entirely does. Under the impression it replaces periods with commas.<br></div></div></blockquote></div><div><br></div><div>Yes that's correct. This is historical and harks back to the days of xymon's forerunner, BigBrother. MACHINEDOTS is the FQDN hostname with dots as normal, MACHINE is the same but with commas instead. Xymon doesn't care, but its the convention.</div><div><br></div><div>Running your script under xymoncmd will setup these two variables for you.</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 30, 2016 at 2:10 AM, Jeremy Laidman <span dir="ltr"><<a href="mailto:jlaidman@rebel-it.com.au" target="_blank">jlaidman@rebel-it.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Can you show the exact errors? Also, show the whole script?<br>
</p>
<br><div class="gmail_quote"><div dir="ltr">On Thu, 30 Jun 2016, 01:16 Joshua Hunt <<a href="mailto:joshuasocrates@gmail.com" target="_blank">joshuasocrates@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">So I'm trying to implement a server script, and I'm getting some errors with the beginning of my code, specifically the section that ties to Xymon. <div><br></div><div>HOSTTAG="tag"</div><div>COLUMN="$HOSTTAG"</div><div><br></div><div># Here is where I get my first error. Directory apparently does not exist. However, later in the script </div><div>I source from a similar location and all works fine. I have manually checked, this location does exist.</div><div>$XYMONHOME/server/bin/xymongrep "$HOSTTAG" | while read L</div><div>do</div><div><br></div></div>
_______________________________________________<br>
Xymon mailing list<br>
<a href="mailto:Xymon@xymon.com" target="_blank">Xymon@xymon.com</a><br>
<a href="http://lists.xymon.com/mailman/listinfo/xymon" rel="noreferrer" target="_blank">http://lists.xymon.com/mailman/listinfo/xymon</a><br>
</blockquote></div>
</blockquote></div><br></div>
</blockquote></div>