cgi

Run a cgi shell script in background

房东的猫 提交于 2019-12-01 09:32:06
I've a cgi shell script like this #!/bin/sh # show the page echo Content-type: text/html echo echo "<html><b>Hello world!</b></html>" # the task I want to do in background sleep 100 echo $(date) >> log I want to page to show after the last echo , not at the end of the execution of the script. I've tried putting the code in another file and execute it like this ./background.sh & . It works in console but not in the browser. I use lighttpd Aaron Digulla Close stdout with exec >&- before you execute your long-running or background task. Maybe you'll also have to close stderr. That would be exec >

File Sharing Site in Python

[亡魂溺海] 提交于 2019-12-01 08:04:43
I wanted to design a simple site where one person can upload a file, and pass off the random webaddress to someone, who can then download it. At this point, I have a webpage where someone can successfully upload a file which gets stored under /files/ on my webserver. The python script also generates a unique, random 5 letter code that gets stored in a database identifying the file I have another page called retrieve, where a person should go, put in the 5 letter code, and it should pop up a filebox asking where to save the file. My Problem is that: 1) How do I retrieve the file for download?

How set an environment variable in PHP with Apache/FastCGI?

我是研究僧i 提交于 2019-12-01 08:00:00
问题 I need to define an environment variable named SQLANY17 and this variable should be available in PHP (i.e. under "Environment" in the standard phpinfo() page). PHP is executed via FastCGI and I'm running CentOS 7 x64, Apache 2.4.6 and PHP 5.5.30. I've edited /etc/httpd/conf.d/fcgid.conf which already exists in my distribution. According to the documentation an environment can be defined using FcgidInitialEnv. <IfModule mod_fcgid.c> # ... FcgidInitialEnv SQLANY17 /opt/sqlanywhere17 </IfModule>

Running python script from php

末鹿安然 提交于 2019-12-01 07:51:44
问题 I am trying to run a python script from php. exec("../cgi-bin/form.py", $output); var_dump($output); I'm certain the path is correct, and that form.py is executable. this is form.py #!/usr/bin/env python print "IN form.py' However, this prints out NULL. I don't think the script is being executed. How do I make sure it is? 回答1: You're literally just typing in the location of the file. You need to tell exec to execute python with that script. exec("python ../cgi-bin/form.py", $output); 来源:

Why is my image download CGI script written in Perl not working?

强颜欢笑 提交于 2019-12-01 07:26:54
问题 #!/usr/bin/perl use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); my $files_location; my $ID; my @fileholder; $files_location = "C:\Users\user\Documents\hello\icon.png"; open(DLFILE, "<$files_location") ; @fileholder = <DLFILE>; close (DLFILE) ; print "Content-Type:application/x-download\n"; print "Content-Disposition:attachment;filename=$ID\n\n"; print @fileholder; When I run this script, instead of returning the icon.png file it returns the download.pl (the name of the script given

How to maintain sessions with C++ code?

谁说我不能喝 提交于 2019-12-01 06:55:41
There is a cgi code written in C++. Currently there is no session management done in the web pages. There is a need to provide sessions in the web pages so that the user can login, maintain session and then logoff. While this is a fairly simple task in java with HttpSession, I have no clue how to do this with C++ code. C++ is not like Java in the breadth of the functionality of the bundled libraries, so you need to extend the language with some extra libraries for not so common tasks (such as C++ CGI development). You can either build the library yourself to support functionality not present

c实现cgi的编写

戏子无情 提交于 2019-12-01 06:43:54
系统:OS X EI Capitan 首先配置apache对CGI的支持 编辑apache配置文件 /Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf 取消注释 描述什么样的文件视如cgi文件,比如以`.cgi`结尾的文件 AddHandlercgi-script .cgi 返回服务器返回形式 AddType text/html.shtml AddOutputFilterINCLUDES .shtml 检查cgi_module是否被注释掉了: LoadModule cgi_module modules/mod_cgi.so 找到并在原有内容上添加以下代码 <Directory> Options Indexes FollowSymLinks MultiViews ExecCGI DirectoryIndex index.html index.cgi AllowOverride None Order allow,deny Allow from all </Directory> 重启 apache 首先编写一个简单的CGI文件 #include<stdio.h> int main(){ printf("Content-Type:text/html;charset=gbk\r\n\r\n"); printf("<html><head

How can I continuously inform the user of progress from a Perl CGI script?

筅森魡賤 提交于 2019-12-01 06:31:13
I have this Perl script sitting in the cgi-bin folder of my Apache server: #!/usr/bin/perl use strict; use warnings; $| = 1; print "Content-type: text/html\r\n\r\n"; print "Hello there!<br />\nJust testing .<br />\n"; my $top = 5; foreach (1..$top) { print "i = $_<br />\n"; sleep 1; } What I want to achieve here is a gradual update of the web page to show the user an updated status. However, what I'm actually getting is the entire output at once, after a delay of 5 secs. Is there any way I can write a script that is able to continuously inform the user of its progress? I have a script that

Apache2 sends two HTTP headers with a mapped “nph-” CGI

大城市里の小女人 提交于 2019-12-01 06:26:40
Summary I'm trying to map some file extensions to be executed by a nph (Non Parsed Header) CGI executable. Let's say I want to access a URL http://server/file.ext and map the "ext" file extension to "trigger" the execution of my nph CGI (/var/www/cgi-bin/nph-test.sh). Apache configuration To do that I'm using mod_actions and mod_cgid, this is my relevant configuration information: <VirtualHost *:80> DocumentRoot /var/www/htdocs ScriptAlias /cgi-bin /var/www/cgi-bin Action cgi-wrapper /cgi-bin/nph-test.sh AddHandler cgi-wrapper .ext </VirtualHost> NPH CGI script This is my nph-test.sh shell: #!

nginx如何调用PHP(nginx+php运行原理)

懵懂的女人 提交于 2019-12-01 05:53:04
采用nginx+php作为webserver的架构模式,在现如今运用相当广泛。然而第一步需要实现的是如何让nginx正确的调用php。由于nginx调用php并不是如同调用一个静态文件那么直接简单,是 需要动态执行php脚本 。本文的主要内容为如何在nginx server中正确配置php调 用方法,以及配置的基本原理。知道了配置和基本原理后,我们也就知道了他们之间是怎么通信的。 一、普及Nginx与Php-fpm相关知识点 Nginx是什么 Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。 Php-fpm是什么 1、cgi、fast-cgi协议 cgi的历史 早期的webserver只处理html等静态文件,但是随着技术的发展,出现了像php等动态语言。 webserver处理不了了,怎么办呢?那就交给php解释器来处理吧! 交给php解释器处理很好,但是,php解释器如何与webserver进行通信呢? 为了解决不同的语言解释器(如php、python解释器)与webserver的通信,于是出现了cgi协议。只要你按照cgi协议去编写程序,就能实现语言解释器与webwerver的通信。如php-cgi程序。 fast-cgi的改进 有了cgi协议,解决了php解释器与webserver通信的问题