<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000"><font style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">
See the sudoers file or the man pages for an explanation. There are things that sudo passes by default and things that need to be manually added. I assume a security reason. Basically in sudoers, you can add environment variables to pass through in different cases. <br><br></font><br> <br>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<font style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<b>From</b>: Michael Beatty [mailto:Michael.Beatty@sherwin.com] <br><b>Sent</b>: Wednesday, January 16, 2013 10:44 AM<br><b>To</b>: xymon@xymon.com <xymon@xymon.com> <br><b>Subject</b>: Re: [Xymon] Starting Xymon via init script no environment variables <br></font> <br></div>

    <div class="moz-cite-prefix"><tt>Well... I figured out it has to do
        with how sudo invokes the environment.  I'm pretty sure there is
        a parameter I could supply to sudo to bring in the environment,
        but it was just as easy to switch from sudo to su.<br>
        <br>
        I changed my commands to:<br>
        su - xymon -c "/home/xymon/client/runclient.sh start"<br>
        and it works now.<br>
        <br>
        If anyone who understands this better than me understands why, I
        would appreciate an explanation.<br>
        <br>
      </tt>
      <pre class="moz-signature" cols="72">Michael Beatty
Sherwin-Williams
IT Analyst/Developer
<a class="moz-txt-link-abbreviated" href="mailto:michael.beatty@sherwin.com">michael.beatty@sherwin.com</a>
216-515-7374
</pre>
      On 01/16/2013 08:15 AM, Michael Beatty wrote:<br>
    </div>
    <blockquote cite="mid:50F6A7F0.10107@sherwin.com" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix"><tt>Linux SuSE</tt>.<br>
        <br>
        <br>
        #!/bin/bash<br>
        #<br>
        # xymon      This starts and stops xymon stuff<br>
        #<br>
        # Author:  Michael Beatty<br>
        #<br>
        # description: starts/stops Xymon<br>
        #<br>
        # /etc/init.d/xymon<br>
        #<br>
        ### BEGIN INIT INFO<br>
        # Provides:       xymon<br>
        # Required-Start: $local_fs network<br>
        # Should-Start: mqm  <br>
        # Required-Stop:  <br>
        # Should-Stop:    <br>
        # Default-Start:  <br>
        # Default-Stop:   <br>
        # Description:    Xymon client custom startup<br>
        ### END INIT INFO<br>
        <br>
        # Store variables<br>
        . /etc/sysconfig/posvars<br>
        # Source SuSE config<br>
        . /etc/sysconfig/boot<br>
        <br>
        # Shell functions sourced from /etc/rc.status:<br>
        #      rc_check         check and set local and overall rc
        status<br>
        #      rc_status        check and set local and overall rc
        status<br>
        #      rc_status -v     ditto but be verbose in local rc status<br>
        #      rc_status -v -r  ditto and clear the local rc status<br>
        #      rc_failed        set local and overall rc status to
        failed<br>
        #      rc_failed <num>  set local and overall rc status to
        <num><num><br>
        #      rc_reset         clear local rc status (overall remains)<br>
        #      rc_exit          exit appropriate to overall rc status<br>
        . /etc/rc.status<br>
        <br>
        # First reset status of this service<br>
        rc_reset<br>
        <br>
        # Return values acc. to LSB for all commands but status:<br>
        # 0 - success<br>
        # 1 - generic or unspecified error<br>
        # 2 - invalid or excess argument(s)<br>
        # 3 - unimplemented feature (e.g. "reload")<br>
        # 4 - insufficient privilege<br>
        # 5 - program is not installed<br>
        # 6 - program is not configured<br>
        # 7 - program is not running<br>
        # <br>
        # Note that starting an already running service, stopping<br>
        # or restarting a not-running service as well as the restart<br>
        # with force-reload (in case signalling is not supported) are<br>
        # considered a success.<br>
        <br>
        <br>
        RETVAL=0<br>
        <br>
        <br>
        case "$1" in<br>
            start)<br>
                echo "Staring Xymon Client QMGR = $QMGR"<br>
                 /usr/bin/sudo -u xymon /home/xymon/client/runclient.sh
        start    <br>
                rc_status <br>
                ;;<br>
            stop)<br>
                echo "Stopping Xymon Client QMGR = $QMGR"<br>
                /usr/bin/sudo -u xymon /home/xymon/client/runclient.sh
        stop<br>
                      rc_status <br>
                ;;<br>
            restart)<br>
                /usr/bin/sudo -u xymon /home/xymon/client/runclient.sh
        restart<br>
                rc_status -v<br>
                ;;<br>
            status)<br>
                /usr/bin/sudo -u xymon /home/xymon/client/runclient.sh
        status<br>
                rc_status <br>
                ;;<br>
            *)<br>
                echo $"Usage: $0 {start|stop|restart|status}"<br>
                exit 1<br>
                ;;<br>
        esac<br>
        rc_exit 0<br>
        <br>
        <br>
        <br>
        <br>
        <pre class="moz-signature" cols="72">Michael Beatty

</pre>
        On 01/15/2013 08:03 PM, Jeremy Laidman wrote:<br>
      </div>
      <blockquote
cite="mid:CAAnki7CR+6sOC+hBHOYYtx41UCV3AoNRWhQD_XKnaV0SA-zSfA@mail.gmail.com"
        type="cite">
        <div dir="ltr">What OS?  Can you show the init script?
          <div><br>
          </div>
        </div>
        <div class="gmail_extra"><br>
          <br>
          <div class="gmail_quote">On 16 January 2013 06:44, Michael
            Beatty <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:Michael.Beatty@sherwin.com" target="_blank">Michael.Beatty@sherwin.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">I've got
              an init script that is starting up the xymon client. It
              starts, and runs, however it doesn't appear to have any
              access to any environment variables.  If I restart the
              client from a shell, it takes off and runs fine.  I've got
              echo statements in the init script to display some of the
              environment variables I need, and they are displaying fine
              at boot time.  It just seems that xymon doesn't have
              access to them when it is running.  What has me really
              confused is that I'm even exporting the variable from a
              file directly from the xymon script.<br>
              <br>
              For example, in the init script, I 'echo $HOST'  The host
              name shows up in the log<br>
              I have a perl script that clientlaunch calls, I have a
              variable "my $host = $ENV{"HOST"}.<br>
              <br>
              I am printing the "HOST" variable out to the log file when
              the script runs.  If I start the xymon client from a
              shell, the HOST variable prints out.  However, it doesn't
              print out (just a blank) if the xymon client starts via
              the init script.<span class="HOEnZb"><font color="#888888"><br>
                  <br>
                  <br>
                  <br>
                  <br>
                  -- <br>
                  Michael Beatty<br>
                  <br>
                  _______________________________________________<br>
                  Xymon mailing list<br>
                  <a moz-do-not-send="true"
                    href="mailto:Xymon@xymon.com" target="_blank">Xymon@xymon.com</a><br>
                  <a moz-do-not-send="true"
                    href="http://lists.xymon.com/mailman/listinfo/xymon"
                    target="_blank">http://lists.xymon.com/mailman/listinfo/xymon</a><br>
                </font></span></blockquote>
          </div>
          <br>
        </div>
      </blockquote>
      <br>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Xymon mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Xymon@xymon.com">Xymon@xymon.com</a>
<a class="moz-txt-link-freetext" href="http://lists.xymon.com/mailman/listinfo/xymon">http://lists.xymon.com/mailman/listinfo/xymon</a>
</pre>
    </blockquote>
    <br>
    <br>
  </body>
</html>