Skip to content

Instantly share code, notes, and snippets.

@nfreear
Created May 18, 2021 20:33
Show Gist options
  • Select an option

  • Save nfreear/a17beaeb8ded893d030584a604dcc641 to your computer and use it in GitHub Desktop.

Select an option

Save nfreear/a17beaeb8ded893d030584a604dcc641 to your computer and use it in GitHub Desktop.
CGI Tests, 18-May-2021.

CGI Tests, 18-May-2021


Bash cgi-bin

#!/usr/bin/env sh

echo "Content-Type: text/plain"
echo ""
echo ""

echo Hello world!

echo $(node -v)

# End.

Result :~ 500 error !!

#!/usr/bin/env node

process.stdout.write("Content-Type: text/plain\n\n");

process.stdout.write("Hello world!");

// OR ?!
console.log('Content-Type: text/plain\n\n');

console.log('Hello world!');

// End.

Perl cgi-bin

#!/usr/bin/env perl

=head1 DESCRIPTION

 printenv — a CGI program that just prints its environment

=cut
print "Content-Type: text/plain\n\n";

for my $var ( sort keys %ENV ) {
    printf "%s=\"%s\"\n", $var, $ENV{$var};
}

# End.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment