标签: cgi

如何设计Perl cookie初始化登录屏幕?

基于这个问题,我之前曾问过如何在Perl中设置cookie,我成功地得到了答案和方法,但现在我面临着一个新的有趣挑战.

在Perl CGI脚本中,它要求您在header语句上设置一个cookie,它应该是脚本中的第一个语句.为了澄清,您需要CGI->header()在脚本的顶部添加一条语句,以使CGI脚本正常工作!

我的情景:

我有一个带有用户名和密码的登录屏幕,成功登录后我需要设置一个包含当前用户名的cookie,然后将用户重定向到另一个表单,该表单在允许任何事务之前检查cookie是否已设置.

请注意,如果我在CGI->header()语句之后设置cookie ,它永远不会被设置,如果我将它设置在我的脚本的顶部,它有一个虚假值,原因很明显(用户尚未登录)

我该如何实现这一目标?并在CGI->header()声明中需要在一直是我的脚本的顶部?

迦特

cookies perl cgi

1
推荐指数
2
解决办法
810
查看次数

1
推荐指数
1
解决办法
133
查看次数

CGI错误 - 权限被拒绝

我有一个perl webapp在服务器上工作正常,但在我的本地机器上没有.

Apache日志显示(以及其他错误):

Permission denied at /home/mywebapp/dev/www/index.cgi line 318.
End of script output before headers: index.cgi
Run Code Online (Sandbox Code Playgroud)

318中的index.cgi:

our @gr;
eval('require Groups;');
#close STDERR; <<<< commented
open STDERR, '>1' or die $!;  <<<< line 318
Run Code Online (Sandbox Code Playgroud)

我很感激任何帮助.谢谢!

apache perl webserver cgi

1
推荐指数
1
解决办法
560
查看次数

Perl获取时没有执行错误 - 执行结束时

我当前的perl代码正在运行数据库查询的所有行,然后抛出一个

DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at ./recieveTxn.cgi 
line 168.
Run Code Online (Sandbox Code Playgroud)

在末尾.它几乎就像有些东西没有告诉循环在行的末尾停止,但我已经像其他人一样写了它.

例如:查询会拉高

shortcode1
shortcode2
shortcode3
然后在这里抛出错误

$sql = "
    SELECT
        aPI.folder AS aPIfolder, 
        aPI.rowNum AS aPIrowNum,
        hasInput,
        evalCode
    FROM
        aPersonalItems as aPI
    LEFT JOIN 
        pItems_special_inputs as SI 
    ON
        aPI.folder = SI.folder AND
        aPI.rowNum = SI.rowNum
    WHERE
        hasInput=1 AND
        aPI.folder='$FORM{'folder'}'
    ORDER BY
        aPI.rowNum
";

$sth = $dbh->prepare( $sql );
$sth->execute();

my ($shortcoderow, $row);
my $shortcodeSQL = "
    SELECT 
        * 
    FROM
        pItemsShortCodes 
    WHERE
        folder='$FORM{'folder'}' 
    ORDER BY
        rowNum
";
my $shortcodeSTH = …
Run Code Online (Sandbox Code Playgroud)

mysql perl cgi

1
推荐指数
1
解决办法
1218
查看次数

用python编写cgi脚本

我试图在python3中使用它作为服务器运行一个cgi脚本:

from http.server import HTTPServer, CGIHTTPRequestHandler

port = 8080

httpd = HTTPServer(('', port), CGIHTTPRequestHandler)
print("Starting simple_httpd on port: " + str(httpd.server_port))
httpd.serve_forever()
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

Traceback (most recent call last):
  File "/usr/lib/python3.2/http/server.py", line 1110, in run_cgi
    os.execve(scriptfile, args, env)
OSError: [Errno 2] No such file or directory
localhost - - [21/Nov/2012 10:28:26] CGI script exit status 0x7f00
Run Code Online (Sandbox Code Playgroud)

请帮忙.

python cgi

1
推荐指数
1
解决办法
3027
查看次数

python简单的wsgi文件上传脚本 - 有什么问题?

import os, cgi

#self_hosting script
tags = """<form enctype="multipart/form-data" action="save_file.py" method="post">
<p>File: <input type="file" name="file"></p>
<p><input type="submit" value="Upload"></p>
</form>"""

def Request(environ, start_response):
    # use cgi module to read data
    form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ, keep_blank_values=True)

    try:
        fileitem = form['file']
    except KeyError:
        fileitem = None

    if fileitem and fileitem.file:
        fn = os.path.basename(fileitem.filename)
        with open(fn, 'wb') as f:
            data = fileitem.file.read(1024)
            while data:
                f.write(data)
                data = fileitem.file.read(1024)

            message = 'The file "' + fn + '" was uploaded successfully'

    else :
        message = …
Run Code Online (Sandbox Code Playgroud)

python post cgi wsgi

1
推荐指数
1
解决办法
6141
查看次数

在我的Python CGI脚本中,如何将通过用户在表单中输入的数据的POST请求上传的文件保存到磁盘?

客户端有一个简单的表单,带有文本和文件:

<form name="add_show" id="add_show" action="" method="GET">

    <label class="text-info">Show Name:</label>
    <input type="text" id="show_name" name="show_name" placeholder="My Show Name" required><br><br>

    <label class="text-info">Show's File (JSON):</label>
    <input type="file" id="file" name="file" required><br><br>

    <p><input class="btn btn-danger btn-small" name="button2" value="Add the Show!" onClick="addFullShow(this.form)"></p>

</form>
Run Code Online (Sandbox Code Playgroud)

使用Javascript我将数据发送到服务器的Python CGI脚本:

function addFullShow(form) {

      alert("about to send form");

      var formElement = form;
      formData = new FormData(formElement);

      var xhr = new XMLHttpRequest();
      xhr.open("POST", "myScript.cgi");
      xhr.send(formData);

    }
Run Code Online (Sandbox Code Playgroud)

在服务器端Python CGI脚本中我有字段存储fs = cgi.FieldStorage(),我知道如何获取文本值,即fs['key'].value.

如何保存上传到磁盘的文件?

我希望我足够清楚.谢谢!

javascript python html5 cgi

1
推荐指数
1
解决办法
4498
查看次数

使用perl cgi来获取cookie

我正在尝试在cgi脚本中检查cookie值; 我的测试脚本看起来像

#!/usr/bin/perl -w
use DBI;
use CGI qw/:standard/;
use CGI::Cookie;

my $cgiH = CGI->new;

print header;
print start_html(-title=>'Cookie Terms'), h1("Cookie Terms"), "<hr>\n";

%cookies = CGI::Cookie->fetch;
foreach $k (keys %cookies) {
    my $term = "$cookies{$k}";
    my $term =~ s/SubjectTerm//;
    print "at $k is $term \n";
}

print end_html;
Run Code Online (Sandbox Code Playgroud)

脚本的相关输入(来自HTTP GET)是

Cookie: SubjectTerm1=ponies
Cookie: SubjectTerm2=horses
Run Code Online (Sandbox Code Playgroud)

(这可以通过使用fiddler或调试我的delphi应用程序中的代码来验证).我的脚本(省略HTML包装器)的结果是

at SubjectTerm1 is  
at SubjectTerm2 is  
Run Code Online (Sandbox Code Playgroud)

或者如果我将print语句更改为

print "at $k is $cookies{$k}\n";
Run Code Online (Sandbox Code Playgroud)

它是

at SubjectTerm1 is SubjectTerm1=ponies; path=/
at SubjectTerm2 is SubjectTerm2=horses; path=/
Run Code Online (Sandbox Code Playgroud)

我想要到达的是这样的

at …
Run Code Online (Sandbox Code Playgroud)

cookies perl cgi

1
推荐指数
1
解决办法
895
查看次数

如何在perl cgi url参数中处理'&',其中参数值包含'&'符号

我试图在URL中传递参数并使用param()读取参数.我的一个参数值包含一个'&'符号,因此在通过param()读取值时,它会在'&'之后跳过该部分.有没有什么方法可以使用这种方法而不会损害包含'&'的值?

例:

HTTP:// someurl /品牌=贝尔%20&%20Ross&类别=手腕%20Watch%20Dealers&qq_cat_id = 8798798

参数品牌的价值是"贝尔",而不是"贝尔和罗斯".

perl cgi

1
推荐指数
1
解决办法
155
查看次数

迁移到新服务器后,Perl CGI每日图片脚本的行为不符合预期

我有一个perl cgi脚本,在FreeBSD 5.4 Apache 1.3网络服务器上使用了很多年,没有任何问题.这是当天脚本的图片,它随机选择给定目录中的图片以包含在服务器端包含的shtml页面中

<!--#exec cgi="/cgi-bin/pod/pod.cgi"-->
Run Code Online (Sandbox Code Playgroud)

我最近迁移到了Google云平台上的新服务器 - Debian 9(Stretch),Apache 2.4.剧本破了.在设置服务器配置以正确执行cgi perl脚本并以ASCII重新上载脚本之后,脚本再次开始工作,但现在出现了异常行为.而不是整天显示一个图像(同一图像),然后在午夜更改图像(所需的行为),它现在每次在Web浏览器中重新加载页面时都会更改图像.

该脚本使用平面文件日志来跟踪源目录中已使用的图像,并且在使用目标目录中的所有图像(登录pod.log)之前不会重复显示任何图像.正常工作时,它将每天显示一个新图像(午夜更改),对于所有用户,无论页面是否重新加载,都将保持相同,直到下午午夜.

权限已全部设置在脚本注释中指定的必要文件上.该脚本已经以ASCII格式上传到服务器(如果以二进制格式上传,则根本不起作用).该脚本显示正确目录中的图像.但是.....每次刷新页面时,都会加载一个新图像并将其记录到pod.log文件中.

One thing that I thought might be affecting the script was where it was getting the time for the date/time function of the script. When I entered the "date" command from the debian command prompt the server returned the correct time that I had configured the server to - America/Los_Angeles. But I noticed that when files on my webserver were touched or changed, it was …

apache perl debian cgi timestamp

1
推荐指数
1
解决办法
167
查看次数

标签 统计

cgi ×10

perl ×7

python ×3

apache ×2

cookies ×2

debian ×1

forms ×1

html5 ×1

javascript ×1

mysql ×1

post ×1

timestamp ×1

webserver ×1

wsgi ×1