FAQ Database Discussion Community


Python CGI replaces my html

python,html,cgi
I am teaching myself CGI with python and I am having trouble finding any references on how to just insert the output of the python program into my current html instead of replacing the whole existing page. Here is the python: #!python import cgi, cgitb cgitb.enable() form = cgi.FieldStorage() def...

calling cgi script from other cgi script

perl,cgi
I found a puzzling behavior using perl cgi for which -- I guess -- there is a perfectly valid explanation but I couldn't find one. There is this question on stackoverflow, but what it describes seems to fail for me. The situation: I have two perl cgi scripts. One of...

Keep line formatting in browser with bash CGI

bash,browser,formatting,cgi
I'm using this bash CGI: #!/usr/bin/sh echo "Content-type: text/html" echo "" echo `ls -al` And it produces ie: total 52 drwxrwxrwx. 2 root root 4096 Feb 2 18:34 . drwxr-xr-x. 8 root root 4096 Feb 2 17:58 .. -rw-r--r--. 1 root root 36310 Feb 2 17:45 dds.jpg -rw-rw-rw-. 1 user...

Raspberry Pi with c++ running thread, publish data on web

c++,webserver,cgi
I would like to show some values handled in my c++ program on a web page, this should be opened from many clients and the web page should be not mandatory for my application. I described these requirements because I getting crazy to solve this issue: I found many samples...

enumeration values in json

python,json,cgi
Do a simple screening values. but do not understand why only takes a few values, not the entire list. I use CGI written in python. displays 136 values, but in the file more than 1000 values. #!/usr/bin/python import json import cgi import cgitb import sys reload(sys) sys.setdefaultencoding('utf8') form = cgi.FieldStorage()...

Passing data from Server in C language to a python script

sockets,network-programming,cgi,server
I am developing a prototype web application. I am using a toy http server which I have developed myself and it is written in C. The server needs to obtain text data from html form submitted and for furthur processing should pass it to a script which I have written...

how to tell cgi to stop waiting

python,cgi
Im running python on serverside and the script would be running for sometime, and I don't want to keep the user waiting. Is there a way to print some html to CGI and tell it to stop waiting for anything more to happen. while the script is still running?...

Apache ignoring httpd.conf assigned path

apache,cgi,httpd.conf
In trying to resolve a path error on my cgi-bin, I've discovered that Apache is looking for it in the wrong place. The error log shows: script not found or unable to stat: /Library/Server/Web/Data/CGI-Executables But my httpd.conf file has: ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Library/WebServer/CGI-Executables/$1" <Directory "/Library/WebServer/CGI-Executables"> AllowOverride None Options None Require all...

Perl CGI::Session - Migrating user sessions to new server, without them knowing it

perl,session,cgi
I need to move our perl apps to a new server, but I don't want everyone to have to re-authenticate when the move is made. I'd like to have our "Home" script redirect over to the new server, pre-plant a cookie, with a corresponding session file in /tmp, for each...

Raw CGI in Python

python,cgi
I created a litlle script but I already have an error, I don't know what causes this or how to fix it, it's on an ubuntu vps, the error is located on this site: http://alfaxtronic.koding.io/python.py This is the Script: #!/usr/bin/python import os import platform import cgitb cgitb.enable() print "Content-Type: text/html"...

Anomaly with a input with C++ CGI script

c++,apache,cgi
i'm working on a CGI script which will authorise a person on a server. i am writing this on a C++ using CGI provided by Ubuntu's apache2 server. However, i have encountered a strange anomaly which i cannot understand. The case is the following: As you know, when i have...

serve a stringIO (pdf) as download python

python,pdf,download,cgi
I have a cgi python script which saves a matplotlib generated picture as pdf to stringIO and as png to stringIO. The png picture will be shown on a new page which works well. sio = cStringIO.StringIO() pylab.savefig(sio, format='pdf') sio.close() sio =cStringIO.StringIO() print "Content-type:text/html\r\n\r\n" pylab.savefig(sio, format='png', bbox_inches='tight') print "<html>" ......

Preserving line breaks and formatting with BASH CGI

linux,bash,browser,cgi
I tried this (text/plain content): #!/usr/bin/sh echo "Content-type: text/plain" echo "" echo `ls -al` And this (html content with <pre> tags): #!/usr/bin/sh echo "Content-type: text/html" echo "" echo "<pre>" echo `ls -al` echo "</pre>" In both cases my Bash CGI is outputting everything on one line in my browser's output....

Temperature Converter Perl

html,perl,cgi
I am having trouble with my code. The conversion for both Fahrenheit and Celsius will not display, and when I select "Celsius to Fahrenheit", it gives me the conversion for Fahrenheit to Celsius. I'm not sure what I'm doing wrong. I've already searched for help and have gotten nowhere. So...

Can't call method “add_worksheet” on an undefined value?

excel,perl,cgi,perl-module,cgi-bin
here is my cgi code , perl.xls file is present in the save folder as the script. #!/usr/bin/perl print "Content-type: text/html\n\n"; use CGI; use DBI; use Spreadsheet::WriteExcel; use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); my $cgi = CGI->new; my $workbook = Spreadsheet::WriteExcel->new('perl.xls'); my $worksheet = $workbook->add_worksheet(); $worksheet->write(0,0,'value'); And when i...

How to properly escape quotes inside form INPUT attribute assignments?

attributes,cgi,quoting
I have various things that need to end up in a CGI form, thus: <INPUT TYPE="TEXT" SIZE=64 MAXLENGTH=64 NAME="name" VALUE="thing"> ...my understanding (limited, but I'm learning) is that CGI inputs require double quotes as delimiters. However, some of the things I need to put in there have double quotes. Some...

First number in JSON parsed with CJSON is always 0

c,json,cgi
I'm trying to parse a JSON file received by a CGI file on a webserver using cJSON however the first number in the JSON keeps getting changed to 0. I've made a short piece of code which I'm using to test this: int main(int argc, char *argv[]) { cJSON *pstReq;...

How to make Apache execute a CGI (smokeping) rather than display it ? (but it works for PHP)

apache,perl,cgi
I'm under a Redhat 5.11 and try to use Smokeping (a Perl CGI) into apache. Whatever the change I make, the source code of smokeping is displayed rather than executed : I have already followed this documentation : http://httpd.apache.org/docs/2.2/fr/howto/cgi.html mod_perl, mod_alias and mod_cgi seams installed (I can see perl_module (shared),...

Open a program in linux using a web interface

linux,apache,cgi
Is there any way to open a program such as a webbrowser on a linux machine using a webinterface? I tried a simple cgi script #!/bin/bash echo "Content-type: text/html" midori exit 0 But I'm getting a response on the page the browser can't open an interface......

Python CGI getting 500 Internal Server Error

python,apache,cgi
I'm making first python script. I've uploaded the script in public_html/cgi-bin folder with 777 permission. I'm getting this 500 Internal server error. I've wrote the following code. #!/usr/bin/python print "Content-type: text/html\r\n" print "<html><head><title>CGI</title></head>" print "<body>" print "hello cgi" print "</body>" print "</html>" ...

Nginx map client certificate to REMOTE_USER for uWSGI with fallback to basic auth?

ssl,nginx,mercurial,cgi,uwsgi
I'm using Nginx with uWSGI to serve Mercurial; it does basic auth over SSL (Nginx is the SSL terminator; it doesn't get passed on to Hg), but due to the limited security of basic auth even over SSL, as discussed at various places including this site, I want to allow...

Are there any speed benefits when loading modules just before usage in CGI?

python,python-2.7,cgi
I'm building a web application using CGI in Python. Since the script foo.py needs to be loaded every time it's called at mypage.com/foo.py I'm looking for some ways to speed up the initialization. When using a framework such as Django or web.py I always load the modules at the top...

Perl CGI sending null values to mySQL database?

html,mysql,perl,cgi,dbi
Scenario: I have a HTML form that sends variables to a Perl CGI which then takes them and inserts them on to a SQL DB I created earlier, but the problem is that it sends only NULL values to the DB - it does send the "correct number" of nulls...

Adding Å,Ä and Ö to sqlite table through python 2.7, cgi and html post

python,sqlite,python-2.7,cgi,decode
I'm using cgi, python 2.7 and sqlite. I'm trying to insert an string? that contains the characters å,ä and ö into an sqlite table. the string are taken from an html post using cgi this code in takes the value: print '<form action="./printusername.cgi" method="post">' print 'First Name: <input type="text" name="first_name">'...

How can I combine these two statements?

perl,xampp,cgi
I'm currently trying to insert data into a database from a text boxes, $enter / $enter2 being where the text is being written. The database consists of three columns ID, name and nametwo ID is auto incrementing and works fine Both statements work fine on their own, but because they...

NameError : name 'pass_result' not defined line 25?

python,html,cgi,nameerror
Index.html: <html> <head> <title>Login Page</title> <link type="text/css" rel="stylesheet" href="coach.css" /> </head> <body> <img src="images/logo-cel-transparent_0.png" width="74" height="64"><strong><img src="images/logo-cel-transparent_0.png" alt="Cel logo" width="74" height="64" align="right"> </strong> <h1 align="center"><strong>Central Electronics Limited</strong></h1> <p>&nbsp;</p> <h2...

TCP/IP in C not working

c,tcp,cgi
I am having trouble getting my TCP/IP connection between my client and server working. Here is the server code - int main() { int servSock; /* Socket descriptor for server */ int clntSock; /* Socket descriptor for client */ unsigned short echoServPort; /* Server port */ struct sockaddr_in echoServAddr; /*...

Questions about Rasterization: Stochastic Sampling, Pineda Edge Function and Fixed Point Numbers

c++,cgi,rendering,rasterizing
I am trying to study/understand the rasterization algorithm and have already posted a few posts which are related to this and unfortunately didn't get many answers: Rasterisation Algorithm: finding the "ST" coordinates of point in 2D quad and Inverse Projection In the first question I wanted to rasterize a quad,...

Get username on Server that uses digest authentication (Perl)

perl,cgi,digest-authentication
I have a webserver, and on this server I am offering some content that is restricted. Users must log in via digest authentication. This woks fine, since till now all users saw the same content. But now I want to write a cgi-script in Perl, that needs to know the...

How to Reuse Database Connection under Python CGI?

python,cgi
I'm new to python and mysql-python module. Is there any way to reuse db connection so that we may not connect() and close() every time a request comes. More generally, how can I keep 'status' on server-side? Can somebody give me a tutorial to follow or guide me somehow, lots...

Socket connection from compiled c.cgi

c,sockets,cgi
On linux I want to connect to a demon, via a socket in a compiled c.cgi program (cgic), which is listening for incoming socket connections. I know the server works because it will responded to 'nc' commands. Assume the server is black-boxed, I can't change it. In my client program...

When is CGI/FastCGI required and when it is not

django,angularjs,nginx,cgi,wsgi
This is propably a little noob-question, but I have read enough about CGI/FastCGI/WSGI and still not understood completely, so I decided to ask it. First, I want to say what I have understood. I have understood that CGI is an interface program between a web server (for example Apache or...

Toggle low state won't be sent to python cgi

javascript,python,html,cgi,togglebutton
I'm trying to send the state of a bootstrap toggle button to a python cgi script. It works fine when the toggle is true (python script prints "true") but when false, the python script prints "None" as if the input value I try to send was empty. The console.log(tgl_state); prints...

else clause to repeat ajax triggers too many times

javascript,jquery,ajax,error-handling,cgi
I have an ajax function on my website which calls a cgi script. infrequently, this script returns a 500 error. I am trying to change the AJAX call so that when this happens, it will repeat the request. I have tried to do that as follows: function shelverx() { if...

Is MySQL Connector C++ cgi program vulnerable to MySQL injection just like php is?

c++,mysql,security,cgi,mysql-connector
I am making a cgi program using C++. It allows users to register their information on the website and also login. I am worried about security. Normally, MySQL is vulnerable to MySQL injection when using php to receive form. I am using the MySQL Connector/C++ API. When using C++, does...

.jpg out of .cgi with java (IP Webcam)

java,cgi,processing,webcam
hy there, i hope i can explain my question: i´ve an ip webcam and i want to read&save a .jpg file out of the path webacm-ip-adr:8084/snapshot.cgi i´ve little java experience and would like to program it in processing to keep it simple: i´ve found this link: https://www.java.net/node/702486 but its a...

How to handle 0 Content length in POST request in CGI?

c++,linux,http,cgi
In my CGI application something happens when I pass a 0 content length POST request. Here is my code: char* len_ = getenv("CONTENT_LENGTH"); char* type_ = getenv("REQUEST_METHOD"); if(len_ != NULL) { // The code crashes somewhere here long int len = strtol(len_, NULL, 10); char* postdata = (char*)malloc(len + 1);...

Decode URL in bash

bash,url,web,sed,cgi
I'm trying to decode GET arguments in pure bash. I.e.: hello+%26+world should become hello & world So far I've managed to get this: #!/usr/bin/sh echo "Content-type: text/plain" echo "" CMD=`echo "$QUERY_STRING" | grep -oE "(^|[?&])cmd=[^&]+" | sed "s/%20/ /g" | cut -f 2 -d "="` CMD="${CMD//+/ }" echo $CMD which...

How to run CGI “hello world” with python http.server

python,http,python-3.x,cgi
I am using Windows 7, python3.4.3. I would like to run this simple helloworld.py file in my browser: print('Content-Type: text/html') print( '<html>') print( '<head></head>') print( '<body>') print( '<h2>Hello World</h2>') print( '</body></html>') What I do is: 1) Go to command line "C:\Python" (where my python is installed) 2) run: python -m...

Disconnect Client connected to cgi application

c++,windows,apache,email,cgi
I have a simple C++ CGI Application that receives form data from client. The client is written in C# and uses WWWForm to send and receive data to the C++ CGI Application and everything seems to be working with one exception. For example, when I send a registration form to...

Build cgicc-3.2.16 for Visual Studio 2013

c++,cgi
I want to build cgicc-3.2.16 but it is NOT building. I have tried cmake -G "Visual Studio 12 Win64 with Cmake through VS2013 x64 Native Tools Command Prompt but that didn't work. I am getting the error below : CMake Error: The source directory "D:/Webserver/cgicc-3.2.16/cgicc" does not appear to contain...

FieldStorage input removes some characters

python,python-2.7,cgi
Putting "c++" in a input box, my Python script just receives "c". Here's the HTML code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> </head> <body> <input id="inputtxt" type="text">&nbsp; <a...

Is it possible to use PHP with Mapserver?

php,apache,cgi,mapserver
I am using Apache and Mapserver, for creating a GIS based web application. Mapserver use CGI script. But for some specific purposes I want to use PHP, is it possible to use ? What changes I have to make in Apache's and Mapserver's configuration files? FYI, Mapserver is an Open...

How to change domain in CGI::Session?

perl,session,cookies,dns,cgi
I want to use CGI::Session module in order to implement my website sessions. I want to change session cookie in a way that it will fit to the domain that I want. For example, I have two sites, www.mysite.com and dev.mysite.com In this case I want the session cookie domain...

Reading file in PERL using ActiveX

javascript,html,perl,cgi,activexobject
I have been trying to read a file in PERL using ActiveX Control. I was successful in reading the file using ActiveX Controls in HTML. So I changed the HTML code to PERL cgi using "Print" Statement. After that I am not able to read the file the file using...

On Mac, where can I find git-http-backend?

osx,git,cgi
To install Phabricator, I need git-http-backend (a CGI script). Though this does not come with Mac's nor HomeBrew's git. Where can I find it? I could probably create a shell script named git-http-backend that calls git http-backend (that is, call git with the command http-backend). But how do I deal...

Input parameter for perl CGI script

perl,cgi
I need some insight on my Perl CGI script. First of all all this is running under webmin so i'm doing a custom module. I'm calling a CGI Perl script passing 2 parameter from another Perl CGI. The link I'm calling is in the following format: http://IP:8080/foobar/alat.cgi?sysinfo=xxxxxxx&SR=yyyyyyyy The alat.cgi script...

Can parse GET params from URL

python,python-3.x,cgi
I have file test.py: import cgi, cgitb # Import modules for CGI handling form = cgi.FieldStorage() person_name = form.getvalue('person_name') print ("Content-type:text/html\n\n") print ("<html>") print ("<head>") print ("</head>") print ("<body>") print (" hello world <br/>") print(person_name) print ("</body>") print ("</html>") When I go to www.myexample.com/test.py?person_name=john, the result I get is: hello...

Python CGI with API

python,api,web,cgi
I am quite new to python, I have built some applications in python with CGI and I found cgi is much easier compare to a framework as i have full control on everything. Tried to build a web api through below module but it end up with a web page...

Perl is loading as plain text in browser

html,css,perl,cgi
So, this was working fine two minutes ago and for some reason It has now stopped working. #!/usr/bin/perl # Dan Edwards open (FILE, "donations.txt") || &ErrorMessage; @filemessages = <FILE>; close (FILE); print <<EndHTML; Content-type: text/html <html> <head> <title>Teenage Cancer Research Charity Donations</title> <link rel="stylesheet" type="text/css" href="sponsor.css\"> </head>\ <body > <div...

How to specify Perl version for apache2 mod_cgi?

perl,cgi
I have installed additional versions of Perl on a Fedora 21 system. On the PATH, my custom Perl (5.10.0) has priority over the distro's default Perl (5.18.4) user$ perl -v > This is perl, v5.10.0 built for x86_64-linux root# perl -v > This is perl, v5.10.0 built for x86_64-linux However,...

How to get POST parameters from CGI scripts written in bash?

bash,shell,post,cgi
I'm writing a web application using CGI scripts written in bash. For GET requests, the request parameters are available in a variable named $QUERY_STRING. However, I'm unable to figure out where the similar value would be stored for POST requests. I'm using the following script: #!"c:/msys64/usr/bin/bash.exe" # On *nix, replace...

cgi won't work with boost regex

c++,regex,c++11,boost,cgi
I am attempting to write a cgi program (using cgicc) which incorporates the boost regex library. The program works perfectly with std regex, but I am trying to change to boost regex to test the performance difference. The program also works perfectly if I create an offline version that does...

What is the Ruby equivalent of PHP $_ENV?

php,ruby,cgi,environment-variables
I am writing a small CGI script in Ruby, which logs the data of visitors. I would like to log all CGI environment variables like REMOTE_ADDR, USER_AGENT, HTTP_REFERER etc. It was quite easy to iterate over the $_ENV array in PHP, and dump all the variables to examine them, but...

Disadvantages of using CGI scripts written in C for web server-side?

c,apache,cgi
I'm currently handling the simple server-side for an iPhone app using an Apache HTTP server with CGI scripts enabled and a CGI script written in C to handle requests, reading the HTTP query string and inserting/selecting from an SQLite database as required. From what I've seen, this is a very...

Magick++ to display an image with CGI

c++,imagemagick,cgi,jpeg,magick++
I recently began using Magick++ (C++ API for ImageMagick) with the goal of creating a website that could display randomly generated images. I am trying to write a CGI script which would create a JPEG Image, set the color of its pixels, and then return the image information as Content-type:...

Directory not rendering images because of cgi

apache,.htaccess,cgi,server
My server doesn't render any images under the cgi directory, I know that this is because apache is told to run every file under that directory as a cgi program. I would like to adjust the settings to tell apache to run all the .cgi and .pl as cgi programs...

How to get the authenticated user name under apache while in python code?

python,apache,apache2,cgi
Basically I just need to get the authenticated username from apache2, (for basic / similar authentication schemes) but while in python. In php, this is simple, and looks like this: $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW'];` Here is what the relevent section of the config in the site's sites-enabled config...

CGI echoes POST data - security issue?

javascript,security,cgi
I'd like to generate a file on a website using JavaScript and provide it for download by the user. I learned that this is not possible using plain JavaScript and HTML5. I'm thinking of posting the generated file contents to a CGI function on my server that just echoes the...

Perl - Call PHP file from Perl

php,perl,cgi
phptest.php <?php echo "<h2>PHP is Fun!</h2>"; echo "Hello world!<br>"; echo "I'm about to learn PHP!<br>"; echo "This ", "string ", "was ", "made ", "with multiple parameters."; ?> perltest.cgi #!C:\\Perl\\bin\\perl.exe use DBI; use Archive::Zip; use File::Spec::Functions qw( catfile ); use CGI; require "header.cgi"; my $query = new CGI; print $query->header...

php-cgi environment variable setup

php,c++,post,webserver,cgi
I'm building a small web server in C++, and I'm trying to add support for POST requests for PHP pages at the moment. However, I don't know how I should pass the POST request body to the PHP executable. I've seen some examples where environment variables are set and php-cgi...