CGI-Executables directory

Hi,
I'm trying to set up a simple Apache WebServer on my MacBookPro 10.6.2.
So far, I have it working in as far as if I type http://localhost I get the index page I load into /Library/WebServer/Documents but when I try to get that page to run a CGI script, I get an error saying that the URL cannot be found.
I've placed the CGI script in many different locations;
- /Library/WebServer/CGI-Executables
- /Library/WebServer/Documents
- /Library/WebServer/CGI-Executables/cgi-bin
- /Library/WebServer/Documents/cgi-bin
but none of them make a difference.
Here's my simple index.html page:
<html>
<head>
<title>TEST PAGE</title>
</head>
<body>
HELLO WORLD!
<form action="/CGI-Executables/mycgi.cgi" method="post">
<dl>
<dt> Username <dd> <input name="user" size="50">
<dt> Password <dd> <input name="pass" size="50">
</dl>
<input type="submit" value="Submit">
</form>
</body>
</html>
and here's my cgi script:
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash as CGI"
echo "</title></head><body>"
echo "Hello $(user)"
echo "Today is $(date)"
echo "</body></html>"
Any help appreciated.
Regards,
Dan

Try the server forums or the Unix forum (under OS X Technologies).

Similar Messages

  • Configuring the CGI-Executables folder on the webserver

    would like to install w3perl for squid statistics on a MAC running 10.5, the folder in which to place the perl scripts is indicated as /Library/WebServer/CGI-Executables/w3perl, the scripts are already in this folder
    When i run the installation from the browser, I get an error
    The requested URL /w3perl/confstat.pl was not found on this server
    what could be the problem? the w3perl folder is in the CGI-Executables and the file confstat.pl is in the folder w3per;
    have I not defined the CGI executables folder properly? how do i know i have configured the CGI-executables properly

    If your script is in /Library/WebServer/CGI-Executables/w3perl/confstat.pl then the URL for that CGI would be:
    http://your.server.net/cgi-bin/w3perl/confstat.pl
    The URI needs the leading /cgi-bin in order for Apache to interpret it as a CGI request and route it to the CGI-Executables directory.

  • What is the relationship between CGI-Executables and cgi-bin?

    I am trying to get CGIs working locally on my Mac and am having difficulty understanding the relationship between CGI-Executables/ and cgi-bin/.
    I have activated CGI in my httpd.conf file, and have the following perl test script: /Library/WebServer/CGI-Executables/test.cgi file, and have the file permissions set appropriatly
    If I call the script from the actual url: http://127.0.0.1/CGI-Executables/test.cgi, it doesn't work. If I use: http://127.0.0.1/cgi-bin/test.cgi, it works fine.
    Why cgi-bin and not CGI-Executables? What is the relationship between /Library/WebServer/CGI-Executables/ and cgi-bin?
    And how do I get CGIs working in individual users' Sites/ file? Do all CGIs go in the /Library/WebServer/CGI-Executables/ directory, or can each users' Site/ directory have it's own cgi-bin?
    Ti Powerbook G4   Mac OS X (10.4.4)  

    Now I am having trouble getting CGI to work in the user directories. I have a perl script that works for 127.0.0.1/cgi-bin/test.cgi, but not for 127.0.0.1/~joe/cgi-bin/test.cgi.
    My apache error log says:
    [Tue Feb 14 08:14:23 2006] [error] [client 127.0.0.1] Options ExecCGI is off in this directory: /Users/joe/Sites/cgi-bin/first.cgi
    Permissions for Library/WebServer/CGI-Exectuables/test.cgi and /Users/joe/Sites/cgi-bin/ are 777.
    I think the problem is somewhere in my directory configs. Apache has so many, it's hard to know what's what.
    Here's the first directory directives in httpd.conf:
    # First, we configure the "default" to be a very restrictive set of
    # permissions.
    <Directory />
    Options FollowSymLinks
    AllowOverride Options
    </Directory>
    Farther down, there's this, which I added ExecCGI and index.cgi:
    # Control access to UserDir directories. The following is an example
    # for a site where these directories are restricted to read-only.
    <Directory /Users/*/Sites>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch Includes ExecCGI
    DirectoryIndex index.html index.cgi
    <Limit GET POST OPTIONS PROPFIND>
    Order allow,deny
    Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS PROPFIND>
    Order deny,allow
    Deny from all
    </LimitExcept>
    </Directory>
    Then down at the bottom of the file is something I suspect was added automatically when the user account was created:
    Include /private/etc/httpd/users/*.conf
    <Directory "/Users/joe/Sites/">
    Options Indexes MultiViews Includes
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
    To further confuse things, there is another file /etc/httpd/user/joe.conf that has additional user-directory directives:
    <Directory "/Users/joe/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
    Is there something in all these directory configurations that is preventing the user from accessing cgi-bin? Can I add directives to an .htaccess file in the user directory.
    Ti Powerbook G4   Mac OS X (10.4.4)  

  • Normal CGI-Executables permission problem? and Executing Binary CGIs?

    Running 10.4.7. And we are having the no permission problem when trying to run CGI scripts from within CGI-Executables. I have looked at the httpd.conf file and the line that was supposed to be there is. I also have an alias under the default webserver pointing to it. Any help?
    Also, until then, I made a directory under the main website executable and can run perl cgi files. But I get the following error when running the binary file :
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Thanks,
    Corey

    Forget the CGI-Executables, the Alias was fritzing it up, and deleted the alias and is working. But I am still having the problem of the binary CGI files. The only difference I have on the web server is entropy's PHP5 is installed, but wouldn't think that would be an issue.
    Corey

  • Pointing ItunesU.class to a cgi-bin directory.

    Our school is setting up an ITuneU page and we have successfully compiled the ITunesU.class file but for some reason our web server does not have a cgi-bin directory to put these files into. Can we put the Java files into a different directory or is cgi-bin required?

    Our Itunes university is up and running.

  • Scripts missing from Library/WebServer/CGI-Executables

    I updated my Tiger system to Leopard, and in general all is well, however, there are no scripts in Library/WebServer/CGI-Executables. I believe there should be at least two, test-cgi and printenv. In fact, I can't find these anywhere on Leopard. Can anyone point me to copies of these scripts? I did not try to use Web Sharing until after upgrading to Leopard, if I put my own script into Library/WebServer/CGI-Executables, my browsers do access it correctly.

    I have none in either Tiger or Leopard, but then I've never run a webserver. Have you backed up your Tiger installation. If so, copy them from there. If not, bad juju.

  • Running CGI executable in weblogic 6.1

    Hi,
    I am trying to run the CGI executable(m/c code)
    "test.exe" located in
    <web-root>/mqconnect/scripts using weblogic 6.1(SP5)
    I have made the following changes to web.xml:
    ------ web.xml ----------------
    <servlet>
    <servlet-name>CGIServlet</servlet-name>
    <servlet-class>weblogic.servlet.CGIServlet</servlet-class>
    <init-param>
    <param-name>cgiDir</param-name>
    <param-value>/mqconnect/scripts</param-value>
    </init-param>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>CGIServlet</servlet-name>
    <url-pattern>*.exe</url-pattern>
    </servlet-mapping>
    ------End of web.xml ----------------
    On trying to execute (URL: http://<hostname>/mqconnect/scripts/test.exe), i get
    the server error
    --------WebLogic Error--------
    Failed to exec CGI script. Return value : 1
    -------- End of WebLogic Error--------
    Is there something else i should add ot the web.xml to run a CGI executable in
    weblogic (I am able to execute it successfully on Apache Tomcat)
    thx

    Each and every servlet you want acces it should have an entry in web.xml. Otherwise you cant access. (weblogic 6.1 > above)
    -thanks
    Praveen Sadhu.

  • Get current executable directory

    let's say the current start.jar file is running in direct //abc/dc/
    how do I get this directory so I save user customizable configuration to it? I need something that can works on multiple operating system, just just limiting toward windows thanks.

    not sure what I did wrong but I could get all 5 items.
    for (String s : p.childrenNames()) {
                     jTextPane1.setText(s + "");
                }this one returns only "jdumper" and nothing else
    for (String s : p.keys()) {
                     jTextPane1.setText(s + "");
                }returns only the last key stored.
    the weird thing is, Sun wouldn't let us specify which node to write to ...but it allows to retrieve from a certain node. Not sure how does that logic works.
    here is how I write:
    Preferences p = Preferences.userRoot();
    p.put("Operators", jTextField1.getText());
    p.put("Make", jTextField2.getText());
    p.put("Model", jTextField3.getText());
    p.put("Version", jTextField4.getText());
    p.flush();and here is how I get
    jTextField1.setText(p.get("Operators", ""));
    jTextField2.setText(p.get("Make", ""));
    jTextField3.setText(p.get("Model", ""));
    jTextField4.setText(p.get("Version", ""));Is there another way to dump everything out into jTextPane? I'm pretty sure all 4 keys got stored because I was able to retrieve them so they're inside somewhere, I just need to dump them all out into one container.

  • World Writeable, World Executable Directory on Every Mac?

    The permissions on /users/shared are 777.  That's world writeable, world executable, by anyone, anywhere.
    What am I missing?

    Good to know.  I'll double check it. Thanks for posting.

  • Configure tcl for cgi on linux

    Hi team,
    Any pointers on how I can set up cgi -tcl on apache on Red hat 4??
    Any help will be greatly appreciated...
    Thanks,
    Venkat

    Hi Philbert,
    > do you know of an easier way to set permissions
    than the terminal and command line?
       Sometimes it helps to do things the "hard way" so that they become easier. However, we don't like doing repetitive tasks in the command line either. You could put the following in an AppleScript:
    do shell script "chmod -R u+x /Library/WebServer/CGI-Executables/*; chown -R www:www /Library/WebServer/CGI-Executables/*" with administrator privileges
    Then save it as an application. Then when you double-click on it as an administrator and authenticate, the permissions and ownership will be changed.
       Of course if you're really smart and prone to study, you would figure out how to use launchd and its WatchPaths option so that ownership and permissions are changed automatically when a file is dropped into CGI-Executables directory.
    Gary
    ~~~~
       How do I type "for i in *.dvi do xdvi i done" in a GUI?
          (Discussion in comp.os.linux.misc on the
          intuitiveness of interfaces.)

  • Can't execute cgi scripts outside the default

    I had this working fine on my old imac.
    On my new mac (Running Latest Lion)...
    I edited /etc/apache2/httpd.conf
    Updated
    User wtfuser
    Group staff
    Updated
    DocumentRoot "/Users/wtfuser/Sites"
    Updated:
    # This should be changed to whatever you set DocumentRoot to.
    <Directory "/Users/wtfuser/Sites">
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#options
        # for more information.
        Options Indexes FollowSymLinks MultiViews ExecCGI
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        AllowOverride None
        # Controls who can get stuff from this server.
        Order allow,deny
        Allow from all
    </Directory>
    I can execute cgi scripts if they are placed in /Library/Webserver/CGI-Executables
    But if I put a test.cgi file inside /Users/wtfuser/Sites/test.cgi
    I get permission denied and errors:
    [Wed May 02 22:38:45 2012] [error] [client ::1] Options ExecCGI is off in this directory: /Users/wtfuser/Sites/sandbox/test.cgi
    [Wed May 02 22:38:45 2012] [error] [client ::1] File does not exist: /Users/lonewolf/Sites/favicon.ico
    [Wed May 02 22:40:07 2012] [error] [client ::1] File does not exist: /Users/lonewolf/Sites/favicon.ico
    [Wed May 02 22:40:14 2012] [error] [client ::1] File does not exist: /Users/lonewolf/Sites/favicon.ico
    [Wed May 02 22:40:24 2012] [error] [client ::1] File does not exist: /Users/lonewolf/Sites/favicon.ico
    [Wed May 02 22:40:25 2012] [error] [client ::1] File does not exist: /Users/lonewolf/Sites/favicon.ico
    [Wed May 02 22:40:25 2012] [error] [client ::1] File does not exist: /Users/lonewolf/Sites/favicon.ico
    Any help is appreciated

    I will send an update.
    I changed this line
    ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Users/wtfuser/Sites/$1"
    This allowed me to successfully change the location of cgi scripts to a more convenient location, or simply because I wanted to do it! Just because!
    It seems like the AddHandler, and the ExecCGI isn't working. This should allow me to run .cgi files from anywhere, regardless of the script alias.
    So I'm open to suggestions as to why this isn't working.  FYI. I copied my httpd.conf file from my old imac running lion onto my new imac, and it still didn't work. But it works as expected on my old imac.
    Confused. But at least I have a work-around and I know the httpd.conf file I'm modifying is the right one, etc...
    ANd what in gods name is that crap with the favicon.ico?
    This is a brand new out of the box imac, or so I thought. Is this normal??

  • How to Add a New CGI-Handler to Web Server?

    I need to setup a website that will have pages coded in "LiveCode" (http://livecode.com/), an English-like scripting language, that can be used as an 'easier-to-program' replacement for PHP. It has its own interpreter ("livecode-server"), which is supposed to work under Apache as a cgi script. The idea is that the programmer writes web pages in LiveCode, composed of HTML with embedded LiveCode scripting, and these pages are saved using their own extension (".lc"). When a ".lc" page is requested, Apache should send the page for processing by the 'livecode-server' cgi.
    The installation instructions for 'livecode-server' are quite simple. They state that it should be able to be easily installed via an '.htaccess' file, like this:
    1) in the website's root directory, add a ".htaccess" file with the following directives:
    Options ExecCGI
    AddHandler livecode-script .lc
    Action livecode-script /cgi-bin/livecode-server
    2) put the 'livecode-server' executable inside your 'cgi-bin' folder
    These instructions are obviously for users in a shared host environment, but I thought I should be able to do the same with OS X Web Server. But... where can I find a site's "cgi-bin" folder?
    Any guidance is truly appreciated.

    I tried using a custom httpd_livecode.conf file, and storing it in /Library/Server/Web/Config/apache2/other, but without success. To be totally honest, I'm not certain as to whether the configuration is not loading, or whether there is just something wrong with my syntax, and right now I just don't have the time to troubleshoot.
    I did manage to get it working with the .htaccess file, which was quite easy, once I knew where to put the executable - which, as you mentioned, had to be in /Library/Server/Web/Data/CGI-Executables.
    So, for future reference, the 'recipe' for adding a new cgi handler via .htaccess is:
    place the cgi executable (usually a language parser or interpreter) into
    /Library/Server/Web/Data/CGI-Executables
    make sure the parser/interpreter (and any accompanying files or directories) are readable and executable (usually permissions should be set to '755')
    in your site folder, add a .htaccess file with the following contents:
    Options ExecCGI
    AddHandler script-type .extensionType
    Action script-type /cgi-bin/script-interpreter
    In the case of LiveCode, my .htaccess file looks like this:
    Options ExecCGI
    AddHandler livecode-script .lc
    Action livecode-script /cgi-bin/livecode-server
    And the 'livecode-server' executable, as well as its accompanying files, were downloaded directly from the LiveCode website, and placed in /Library/Server/Web/Data/CGI-Executables.
    last of all in Server.app, in the Advanced settings for your site, make sure you have enabled "Allow overrides using '.htaccess' files"

  • Error with opening a connection to a url (for cgi use)

    i still am having trouble using a cgi executable on my server, but i cant seem to narrow down what my problem is.
    i followed the following tutorial, but am still getting errors.
    http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html
                  //  first of all, am I doing this right? all the examples leave out the '.cgi' at the end, why?
                  //does it matter? i tried both ways, i even tried with the ?var1=something stuff at the end. nope.
                  url = new URL("http://www.somewhere.com/" + "write.cgi");
                  urlConnection = url.openConnection();
                  urlConnection.setDoOutput(true);
                  // here is where I get an IOException error ----  error.getCause() yields an output of null
                  PrintWriter out = new PrintWriter(urlConnection.getOutputStream());
                  // i also am not sure how sending to the cgi works. my cgi file was written to parse a string
                  // such as this: "http://www.somewhere.com/fileio.cgi?field1=something&field2=something+else"
                  out.println("whatever i need to send it")
                  out.close();is it possible i'm getting this error because my cgi file isnt set up right? i am confident that it is ok, but i dont know for sure, nor do i know how to test it. typing in
    /fileio.cgi?field1=something&field2=something+else into the working directory of my webpage yields an error that says something like that page isnt readable. i had hoped i could test the cgi this way...is there another way?
    thanks!

    Using the URLConnection output stream doesn't append attributes to the url. If you want to send parameters on the url use
    url = new URL("http://www.somewhere.com/write.cgi?field1=something&field2=something+else");

  • Upload client to server virtual directory - Urgent

    Hai experts,
    Now i am doing a intranet project.
    In that project, user has to upload his
    own datas. That data has to be stored in
    my virtual directory(c:\ramesh). From the
    virtual directory i will take the user
    files thru my procuedures.
    How to copy the client file to my virtual
    directory thru Portal.
    It is very urgent me, Please give me
    any solution
    Regards
    Ramesh.G

    CGI PERL Example to Upload Files
    Step 1:
    add two directories on httpd.conf file:
    /example_cgi/html/ NR /html/
    /example_cgi/cgi-bin/ CR /cgi-bin/
    Restart Apache.
    Step 2:
    Copy the ex.html to the /example_cgi/html/ directory.
    Copy the ex.pl to the /example_cgi/cgi-bin/ directory.
    (both files are listed in the bottom of this NOTE)
    Step 3:
    Edit the ex.pl file to change the destionation directory on the Web Server,
    the user that launched the file must have written permissions in this
    directory. Set execute permissions on this file via chmod. Change also the
    first line of the file to the directory where you installed the PERL
    interpreter. Also change the donepage, to some result page that you want.
    Step 4:
    Call the page, by using http://host:port/html/ex.html, browse and find 1 or 2 files in the local
    system, and press the Upload button, the files will be written in the Web
    Server machine in the directory specified in the ex.pl file.
    Files:
    ex.html:
    <html>
    <body>
    <form method="POST" action="/cgi-bin/ex.pl" ENCTYPE="multipart/form-data">
    File 1:
    <input type="file" name="FILE1">
    <br>
    File 2:
    <input type="file" name="FILE2">
    <br>
    <input type="submit" value="Upload!">
    </form>
    </body>
    </html>
    ex.pl:
    #!/usr/local/bin/perl
    ## Path to where you want your files written to.
    ## Attention: do not use a trailing slash
    $basedir = "/tmp";
    ## The page you wish it to forward to when done:
    ## I.E. http://www.mydomainname.com/thankyou.html
    $donepage = "http://www.oracle.com/";
    # Do you wish to allow all file types? yes/no (no capital letters)
    $allowall = "yes";
    # If the above = "no"; then which is the only extention to allow?
    # Remember to have the LAST 4 characters i.e. .ext
    #$theext = ".gif";
    use CGI;
    $onnum = 1;
    while ($onnum != 11) {
    my $req = new CGI;
    my $file = $req->param("FILE$onnum");
    if ($file ne "") {
    my $fileName = $file;
    $fileName =~ s!^.*(\\|\/)!!;
    $newmain = $fileName;
    if ($allowall ne "yes") {
    if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext){
    $filenotgood = "yes";
    if ($filenotgood ne "yes") {
    open (OUTFILE, ">$basedir/$fileName");
    print "$basedir/$fileName<br>";
    while (my $bytesread = read($file, my $buffer, 1024)) {
    print OUTFILE $buffer;
    close (OUTFILE);
    $onnum++;
    print "Content-type: text/html\n";
    print "Location:$donepage\n\n";
    Good Luck.

  • Web sharing - virtual hosts and CGI

    This topic might be a bit advanced for this forum, I'm not sure. But here goes.
    I'm trying to set up my laptop to act like a web server so that I can do test development on it. I have two web sites, and have successfully created virtual hosts for each of them.
    The part that I'm struggling with now is enabling CGIs, as I want to learn to write CGIs in Perl. I can't seem to find any site that discusses how this is done in Leopard. One said something like "just put the CGIs into /Library/WebServer/CGI-Executables and it'll work", but of course, since I've got virtual hosts defined, it seems that anything addressed to "localhost" defaults to the first virtual host and thus there is no way to refer to a CGI placed in that location. Besides which, I'd like to know how to enable CGIs placed in a folder on each of my virtual sites, so that I could test them in place.
    Any ideas?

    One said something like "just put the CGIs into /Library/WebServer/CGI-Executables and it'll work", but of course, since I've got virtual hosts defined, it seems that anything addressed to "localhost" defaults to the first virtual host and thus there is no way to refer to a CGI placed in that location.
    That is an incorrect assumption.
    By default, Apache is configured to recognize any URI that begins with /cgi-bin and serve that request via a CGI script in /Library/WebServer/CGI-Executables
    This is true even though each site's DocumentRoot is set somewhere else on the file system (that's by design since it makes it harder for a remote attacker to affect your CGIs)
    Since it does not matter which site the request was on, any /cgi-bin request would be served from there, so:
    http://www.domain1.com/cgi-bin/some.cgi
    http://www.domains2.net/cgi-bin/other.cgi
    would both be served from /Library/WebServer/CGI-Executables even though they are for two different virtual hosts.
    Now, of course, if you want each site to be separate and have its own set of CGIs (maybe some.cgi for domain1 does something different from some.cgi on domain2) then this approach causes problems. For this you will need to edit each site to have its own cgi-bin directory.
    Unfortunately (although I haven't tested it) I think Matt's solution won't work because Apache is going to catch all /cgi-bin/ requests and serve them from /Library/WebServer/CGI-Executables, never getting to the cgi-bin directory within each site's documentroot.
    To set site-specific CGI directories you need to add a ScriptAlias command to each site's .conf, such as:
    ScriptAlias /cgi-bin/ /path/to/site/cgi-bin/
    This tells apache that any request for /cgi-bin/* should be served from /path/to/site/cgi-bin
    Ideally the path should be outside of the site's normal document root, but it can be inside if you really want.

Maybe you are looking for