<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Hi Jeff,<br>
      <br>
      <i>i am not shure, that this will be run ok.<br>
        That was not the full line to call. I had think, that was only
        something to change in fcgiwrap.<br>
        This was a part from a ZTP .<br>
        Here the full python script, which run without changing under
        apache2 with mod_cgid.<br>
        <br>
-------------------------------------------------------------------------------------------------------------------------------------<br>
        #!/usr/bin/python3<br>
        <br>
        import os<br>
        environ = os.environ<br>
        serial = "unknown"<br>
        ztp_server = "10.1.8.241"<br>
        <br>
        if "HTTP_X_ARISTA_SERIAL" in environ:<br>
            serial = environ["HTTP_X_ARISTA_SERIAL"]<br>
        serial = serial.strip()<br>
        print("Content-Type: text/plain")<br>
        print()<br>
        print(f"""#!/usr/bin/Cli -p2<br>
        enable<br>
        zerotouch script-exec-timeout 18000<br>
        copy http://{ztp_server}/ztp/EOS-4.30.1F.swi
        flash:EOS-4.30.1F.swi<br>
        copy
        http://{ztp_server}/cgi-bin/ztp/create-startup-config.py?{serial}
        flash:startup-config<br>
        config<br>
        boot system flash:EOS-4.30.1F.swi<br>
        reload<br>
        """)<br>
------------------------------------------------------------------------------------------------------------------------------------<br>
        The </i><i>create-startup-config.py run correkt, i have it
        tested with a manual call. </i><br>
      <i><br>
      </i>Am 27.12.2024 um 22:36 schrieb Jeff Dyke:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAHmnZdYkBZLh+JUdnq-+ByKSC_J+fau6eLOn2z_y=S305=YKyg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div>Pass {serial} to your proxy from a normal nginx args
            variable.  <br>
          </div>
          <div>location /another_script {<br>
          </div>
              proxy_pass <a
            href="http://server/cgi-bin/another_script.py?%7Bserial%7D"
            rel="noreferrer" target="_blank" moz-do-not-send="true">http://server/cgi-bin/another_script.py?</a>$args</div>
        <div>}<br>
        </div>
        <div>And then you'll likely want to change from environ to the
          query string.  I would also make this ?serial=foo.  As the
          query params are converted to a dict/dataclass.</div>
        <div><br>
        </div>
        <div class="gmail_quote gmail_quote_container">
          <div dir="ltr" class="gmail_attr">On Fri, Dec 27, 2024 at
            4:15 PM Ralf Figge via nginx <<a
              href="mailto:nginx@nginx.org" moz-do-not-send="true"
              class="moz-txt-link-freetext">nginx@nginx.org</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
            <br>
            i am a newbee from nginx. I need to run a python script via
            cgi-bin. I <br>
            search for information about python and nginx, and found
            fcgiwrap und <br>
            uwsig.<br>
            I test uwsig (as cgi-bin), but there i become only error 502
            Gateway <br>
            error. fcgiwrap looks like better, But i have 1 problem with
            it:<br>
            Here some code for the sript;<br>
            ----------------------------<br>
            #!/usr/bin/python3<br>
            <br>
            import os<br>
            environ = os.environ<br>
            serial = "unknown"<br>
                 serial = environ["SERIAL"]<br>
            serial = serial.strip()<br>
            ...<br>
            <a
href="http://server/cgi-bin/another_script.py?%7Bserial%7D"
              rel="noreferrer" target="_blank" moz-do-not-send="true">http://server/cgi-bin/another_script.py?{serial}</a><br>
            ---------------------------------------------------<br>
            <br>
            My Problem is, that the call "another_script.py" does not
            have the <br>
            parameter "?{serial}". (i make a tcpdump from the interface)
            Has <br>
            somebody any idea, why it doesn´t go with fcgiwrap?<br>
            <br>
            It runs under Debian 12, python 3.12, nginx 1.26.2 .<br>
            <br>
            regards<br>
            Ralf<br>
            _______________________________________________<br>
            nginx mailing list<br>
            <a href="mailto:nginx@nginx.org" target="_blank"
              moz-do-not-send="true" class="moz-txt-link-freetext">nginx@nginx.org</a><br>
            <a href="https://mailman.nginx.org/mailman/listinfo/nginx"
              rel="noreferrer" target="_blank" moz-do-not-send="true"
              class="moz-txt-link-freetext">https://mailman.nginx.org/mailman/listinfo/nginx</a><br>
          </blockquote>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre wrap="" class="moz-quote-pre">_______________________________________________
nginx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org">nginx@nginx.org</a>
<a class="moz-txt-link-freetext" href="https://mailman.nginx.org/mailman/listinfo/nginx">https://mailman.nginx.org/mailman/listinfo/nginx</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>