r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[CGI] web server issues

Louis
8-May-2006
[476]
exe on Linux?
Graham
8-May-2006
[477x2]
try 
#!/home/daysprin/public_html/cgi-bin/rebol -cs
or check the shebang for any perl scripts you have in your cgi-bin 
directory to see what it should be.
Sunanda
8-May-2006
[479]
okay, forget my fisrt one :-)
Graham
8-May-2006
[480]
the perl scripts may point to a common perl interpreter so may not 
help you either.
Louis
8-May-2006
[481x2]
Graham, that worked! Thanks!.  Why did you use daysprin instead of 
dayspringpublisher.com?
Thanks also to Sunanada.
Graham
8-May-2006
[483x2]
shebangs only refer to the local filing system.  They know nothing 
of web servers which are virtual paths for the web server which is 
an application.
And your web server reported the actual path in the 500 server error 
message.
Louis
8-May-2006
[485x3]
It sure did. I didn't notice that. I will have to start paying better 
attention to what is before my eyes. Thanks again!
OK, now that cgi is working, I want to make a form that will allow 
people to give their name and email address to be saved in a rebol 
db file on the server for me to download at my convenience. Has anyone 
already done this so that I don't have to reinvent the wheel?
Of course, I need the cgi scrpt for this also.
Louis
10-May-2006
[488x3]
What is wrong with this script?

#!/home/daysprin/public_html/cgi-bin/rebol -cs
REBOL []
print "Content-type: text/html^/"

html: make string! 2000
emit: func [data] [repend html data]

read-cgi: func [
    ;Read CGI data. Return data as string or NONE.
    /local data buffer
][
    switch system/options/cgi/request-method [
        "POST" [
            data: make string! 1020
            buffer: make string! 16380

            while [positive? read-io system/ports/input buffer 16380][
                append data buffer
                clear buffer
            ]
        ]
        "GET" [data: system/options/cgi/query-string]
    ]
    data
    probe data
]

cgi-data: decode-cgi read-cgi
print cgi-data
write/append %nr.txt reform [
	now/date
	system/options/cgi/remote-addr
	mold cgi-data
	newline
]
It writes the date and remote-add to the file, but does not write 
cgi-data to the file. What is wrong?
No, I was wrong. It does work. :>)
Janeks
11-Aug-2006
[491]
I am trying for first time to setup rebol for cgi on  remote Apache 
web server on Linux.
I am working from WinXP
Site management is done with EnsimPro. Ftp does not yet working.
So what is done up to now:

Uploaded file Rebol from rebol-core-2602042.tar package for Linux 
to cgi-bin directory;

Set permisions to owner read, write, execute and for group and others 
to read, execute;
Test script -> write file read file,

Test script uploaded (throught web broeser by using EnsimPro web 
interface) test script:

#!/var/www/cgi-bin/rebol -cs

REBOL [Title: "CGI Basics"]

print ["Content-type: text/html" newline]

print "Hello!!!"

to cgi-bin directory;
Set the same permisions.


Pointing to the test file I am getting "500 Internal server errror" 
What else could be wrong?


Interesting that I have interpreters directory on this web server 
where are couple files regarding php and perl.
Could it be connected with my problem?
Pekr
11-Aug-2006
[492x2]
hi, just playing with cgi too .... your cgi-bin directory seems ok 
having 755 rights ....
when I upload my script, I don't feed it with full path, just !#rebol 
-cs, if the interpreter is from the same directory ....
Janeks
11-Aug-2006
[494]
It does not help!
Pekr
11-Aug-2006
[495]
what is your precise mask for script itself? Try giving it 777 for 
a while, to see, if it is permission problem or not ... try to print 
newline at the end of the script ...
Janeks
11-Aug-2006
[496]
Is it o' k that it is just rebol file from linux package and that 
I extracted it on WinXp then uploaded?
What you meant under "mask"?
Pekr
11-Aug-2006
[497x5]
btw - always build your resulting string first out: copy "" ... and 
then everything append out stuff-you-want-to-add .... print out at 
the end ... it is MUCH faster to print everything at once, then to 
print incrementally to the client ...
permissions - xwr-xwr-xwr = 777
uploading should be ok ....
what is your script suffix?
if it is .r, try to change it to .cgi for a while
Janeks
11-Aug-2006
[502]
Already tried!
Pekr
11-Aug-2006
[503]
does any other, etc. pl or shell script work i cgi directory ....
Janeks
11-Aug-2006
[504]
Btw content of one of file in the interpreters dir:
#!/bin/bash
if [ -z "$REDIRECT_STATUS" ]; then
  echo -e "Content-Type: text/html\r\n\r
<b>Security Alert!</b> The Perl CGI cannot be accessed directly.


<p>This Perl CGI launcher is configured to require a redirect.  This

means that a page will only be served up if the REDIRECT_STATUS CGI 
variable 
is set, e.g. via an Apache Action directive.</p>


<p>For more information as to <i>why</i> this behaviour exists, see 
the <a href=\"http://php.net/security.cgi-bin\"> PHP manual page 
for CGI security</a>.</p>

 else
  export SCRIPT_NAME=${PATH_TRANSLATED##${DOCUMENT_ROOT}}
  
 export SCRIPT_FILENAME=$PATH_TRANSLATED
  /usr/bin/perl 
$SCRIPT_FILENAME"
fi


As newcomer in linux and apache I can only ques what it mean, but 
I am thinking about this line:
 This Perl CGI launcher is ...
Pekr
11-Aug-2006
[505x3]
ah, then this apache is configured strangely imo .... in Apache httpd.conf, 
you normally specify ScriptAlias for directory, where cgi is going 
to be placed. Then you can always manually set whatever directory, 
to perform cgi action by adding SetHandler cgi-script for specific 
directory .... but then all files in there are regarded being a cgi 
and Apache could try to run them ...
mostly, if you want to perform cgi outside scriptalias location, 
following directive is uncommented - AddHandler cgi-script .cgi
it seems to me, that this apache, if the perl script is right, is 
unnecessarily configured other way, but du not know ...
Janeks
11-Aug-2006
[508x2]
That web server is hosting and I think that I can not access httpd.conf.
Btw  - where it resides?
The web server service providers told/wrote that it is possible to 
run cgi scripts on this server.
Sunanda
11-Aug-2006
[510]
win --> linux: Does your uploaded script have the right line terminations?
Janeks
11-Aug-2006
[511x2]
I did write file read file.
Before uploading.
Pekr
11-Aug-2006
[513]
janeks, you could try to put .htaccess file into your directory, 
specifying e.g. AddHandler cgi-script .cgi for your directory .... 
it will override httpd.conf settings IF rewriteengine is set to enabled 
...
Janeks
11-Aug-2006
[514x2]
In which directory exactly?
It looks like I need good link to Apache for begginers...
;-)
Pekr
11-Aug-2006
[516]
try your document root directory ...
james_nak
11-Aug-2006
[517]
Janeks,. I think httpd.conf in in the 'confs' dir. I don't think 
that a normal host allows you access to that though.
Pekr
11-Aug-2006
[518]
surely not ...
james_nak
11-Aug-2006
[519x2]
Janeks,  here are some things to try:

1. Make sure you uploaded the rebol exe as binary and the rebol script 
as ascii.

2. make sure you chmod your rebol files, rebol and even the cgi-bin 
(755).

Hope that helps. I have seen the same thing as you many times when 
I first set up rebol.
BTW, if i makes you feel any better, I tested your script in my host 
and it works. I'm wondering if the "#!/var/www/cgi-bin/rebol -cs" 
is not actually pointing to the where it should be. Did the hosting 
company give you the exact path?
Janeks
11-Aug-2006
[521x2]
Thanks all - as always most obvious things are those on which we 
make mistakes.

All was o' k except I changed rebol to rebcore, because I wanted 
also work with Rebol view and ...
... forgot it.
Too much copy & paste.


Well the next question is - if and what else is needed to install 
rebol view for cgi operations?
It even works with .r extension.
Pekr
11-Aug-2006
[523x3]
nothing, but it might eventually not work ...
it all depends, if such machine has X-Windows installed, or not. 
Mine has not IIRC ....
not sure what dependencies are there ..... there might be some library 
missing, as happened with my Command due to AGG