CGI Perl scripts debugging (solve 500 Internal Server Error)

When you run your perl scripts in browser you would get “500 Internal Server Error” when something goes wrong. There would be several reasons of this but one thing to be done is to check if your perl script contains errors. To do it login to server you’re running perl script (I hope you use Linux ;] ) and execute command:

/usr/bin/perl -w /path/to/script.cgi

It will show debug information and it would be much easier to find and solve the problem.

Good luck!

You may also be interested in:
Access to sqlite3 database through perl (script example)

 
 
» You might also be interested in the following articles:
Access to sqlite3 database through perl (script example)
Can’t find usable shell script encryption solution…
FAQ: How to set up atomatic Linux reboot if kernel panic occurs?
Tiny bash scripts: check Internet connection availability
Problem with Vmware Server 1.0.* and kernel 2.4.37



» Want to stay up to date? Subscribe to our E-MAIL or RSS feed!

2 Responses to “CGI Perl scripts debugging (solve 500 Internal Server Error)”


  1. 1 Dion

    Thanks :-)

  2. 2 Tom

    i have a problem to run the script in linux. there is a mistake in the script. so cany you solve for me………

    #!/bin/bash
    # Process each file and link it if it is okay.
    processfile
    {
    lnopts=”$1″
    filename=”$2″

    # file must be “normal file”
    if [ ! -f "$filename" ]
    then
    echo Not a normal file: $filename
    retval=1
    # must have “read perms”
    elif [ ! -r "$filename" ]
    then
    echo “No read permissions: $filename”
    retval=1
    # user must either effective owner the file or effective group owner of the file
    elif [ ! -O "$filename" -o ! -G "$filename" ]
    then
    echo “No effective ownership or effective group ownership of file: $filename”
    retval=1
    # Otherwise all is well, link the file to current directory using existing name
    else
    ln $lnopts $filename
    retval=$?
    fi
    # Return the exit status code > 0 if a problem occured
    return $retval
    }
    # Initialise variables
    cont=’N’
    lnopts=”

    # Process switches
    while test “$1″ = ‘-c’ ‘-o’ “$1″ = ‘-s’
    do
    if [ "$1" = '-c' ]
    then
    cont=’Y’
    shift
    fi
    if [ "$1" = '-s' ]
    then
    lnopts=’-s’
    shift
    fi
    done

    echo “Commencing generation of files

    if [$# -lt 1]
    while read filename
    do
    processfile “$lnopts” “$filename”
    result=$?
    test $result -ne 0 -a “$cont” != ‘Y’ -a “$cont” != ‘y’ || exit 1
    done
    else
    for filename in $*
    do
    processfile “$lnopts” “$filename”
    result=$?
    if [ $result -ne 0 -a "$cont" != 'Y' ]
    then
    echo -n “Error occurred. Continue (y/n/a)? ”
    read $cont
    test “$cont” = ‘n’ -o “$cont” = ‘N’ && exit 1
    [ "$cont" = 'a' || "$cont" = 'A' ] && cont=’Y’
    fi
    done
    fi
    echo “All files processed”

Leave a Reply




Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
TuxArena: The arena of Tux | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››