Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8677783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:33:07+00:00 2026-06-12T20:33:07+00:00

I try to set a variable for a javascript function with my cgi script

  • 0

I try to set a variable for a javascript function with my cgi script hosted on the local IIS(Win7):

cgi:

cout<<"Content-type: text/javascript\r\n\r\n";
cout<<"var value=2;";

javascript:

<script type="text/javascript" src="./cgi-bin/value.exe"></script>
<script type="text/javascript">
<!--
document.write('The number is: ' + value);
-->
</script>

But when i open the html file with the js-code document.write does nothing. And when i analyse the page with firebug a lot of weird characters inside the js-tag and somewhere in the middle of these characters there is my output: “var value=2”.

Has anybody an idea what is going on?
Any help would be greatly appreciated!

EDIT: here a snippet from what firebug tells me is between the script tags:

MZ�������ÿÿ��¸�������@�����

)��")��4)��F)��\)��p)��z)��)��)��)��¬)��Æ)
��Ø)��)��ô(��Ê(��¼  (��°(��¤(��(��(��(�
(��l(��^(��<(��à(����������@���������È@�û��
������bad allocation��Content-type: text/javascript
���var NumberOfFiles = 2; 

?�������������0���������������� ��H���
X@��V�������<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" 
version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b">
</assemblyIdentity>
</dependentAssembly>
</dependency>
/assembly>PAPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDING
XXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADD���0�������

Can anyone tell where this output is coming from?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:33:08+00:00Added an answer on June 12, 2026 at 8:33 pm

    Seems to just fine here. Naturally, you gotta run it from localhost (or some other server)

    testCgi.html

    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript" src="/cgi-bin/cgiBinNum.cgi"></script>
    <script type="text/javascript">
        document.write('The number is: ' + value);
    </script>
    </head>
    <body>
    </body>
    </html>
    

    cgiBinNum.cpp

    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        cout<<"Content-type: text/javascript\r\n\r\n";
        cout<<"var value=2;";
        return 0;
    }
    

    Output:

    <!DOCTYPE html>
    <html><head>
    
    <script type="text/javascript" src="/cgi-bin/cgiBinNum.cgi"></script>
    <script type="text/javascript">
    document.write('The number is: ' + value);
    </script></head><body>The number is: 2
    
    
    
    
    </body></html>
    

    Yeah, the ‘MZ’ gives it away instantly – Mark Zbikowski.

    Basically, it’s actually serving up the exe file itself, not just the result of it.

    If you open the file in a hex-editor, it will look remarkably similar.

    When you say, that’s ‘pretty-much’ what you’ve got, the devil is always in the details.

    Got any more of them?

    I’ve 2 suggestions –
    (1) provide the smallest full source that replicates your problem, as I have done
    (2) change the file extension to .cgi and alter the javascript to reflect this. (You should also get into the habit of adding another build-target to the project and set it’s output folder to your cgi-bin folder, also the extension to cgi, rather than exe) This shouldn’t make a difference to this problem, but it is better in general not to have easily executable files in that folder – easily, as in you can double-click them and they will run, you can always run from the command line if you use a full path, as apache does.

    Ahhh! Just realized you’re using IIS – I think you find that it’s that b@stard of a thing that’s messing up your output. Probably makes point (1) moot – It’s sounding more likely to me that it will be a IIS setting – though it could also be serving the contents of the file, rather than the output – simply based on it’s extension. Give it a try!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<script type=text/javascript> function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(getPostion); } } function getPostion(position) {
Let us start with the Javascript-code: <script type=text/javascript> var parentWindowLocation = ''; // closes
I need to set JavaScript variable by php variable with out ajax. I try
Every time try to set the value of any variable in my model object,
I am trying to set a local variable to an existing binding def foo_callback
try to set host in dsn of pdo like this: <?php /* Connect to
I try to set friendship to method from class GameSimulator on Player class. for
I try to set a timeout on an element, fired with a jQuery plugin.
I try to set an attribute in a XML node using MSXML. IXMLDOMElement alone
I try to set up .hgrc file: [ui] username = MyName MySecondName <mymail@gmail.com> I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.