36 users online (1 members and 35 guests)  


  Results 1 to 10 of 10

Related

  1. Problem with mail-script    Forum: PHP Forum
    Replies: 0
  2. Replies: 0
  3. Executing the PERL CGI Script    Forum: CGI Perl Forum
    Replies: 1
  4. Problem with my script    Forum: PHP Forum
    Replies: 3
  5. Executing A CGI Script?    Forum: CGI Perl Forum
    Replies: 2
  1. #1
    vamshi's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    13

    problem while executing cgi script

    i am getting the problem while executing the HTMl code in cgi script .
    by using print statement it is just printing the html code but not executing in the browser.
    for example: if i load a frame in the print staement in the script it is just printing the frame set code in the browser instead of loading the frame.
    can any one please help in this issue...

  2. #2
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: problem while executing cgi script

    Do you mean that instead of the CODE BEING ANALYSED AND DISPLAYED, you are getting the ACTUAL CODE BEING DISPLAYED.
    i.e. Hello
    is being displayed as
    <font face="arial" size="3" color="red">Hello</font>
    ???
    This is quite often a server issue and you need to consult your hosting company. Sometimes if Perl isn't installed then its possible that it reads the Perl file literally and just prints the code. PLEASE NOTE: if you are trying to test your script locally and don't have Perl installed on your computer then it will just display the code.
    Chris

  3. #3
    vamshi's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    13

    Re: problem while executing cgi script

    Hi thanks for u r reply..
    no problem with perl installation ...coz i have tested with testpage called test.cgi and it is working fine and in the same directory i am using another cgi file which outputs the html code but this page is not executing the HTML code instead it is just printing as it is.

  4. #4
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: problem while executing cgi script

    Could you post your CGI code?
    Another possible problem is that you aren't printing HTML properly. For example:
    Code:
    $print = "<font face=\"arial\" size=\"2\">Hello</font>";
    print "$print";
    # displays "Hello"
    $print2 = qq(<font face="arial" size="2">Hello</font>);
    print "$print2";
    # displays "Hello"
    $print3 = '<font face=arial size=2>Hello</font>';
    print "$print3";
    # displays "<font face=arial size=2>Hello</font>"
    Therefore its likely the way you have used quotes/interpolation. Ill be able to see from your script.
    Chris

  5. #5
    vamshi's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    13

    Re: problem while executing cgi script

    hi i am trying to printing the following code
    print qq{
    <HTML>
    <HEAD>
    <TITLE>Welcome </TITLE>
    </HEAD>
    <FRAMESET COLS="*" frameborder="0" border="0" framespacing="0" marginwidth="0" marginheight="0">
    <FRAMESET ROWS="60,*" frameborder="0" border="0" framespacing=0" marginwidth="0" marginheight="0">
    <FRAME NAME="topnav" SRC="test.cgi?AUTH=$authstring&LEVEL=5&LINK=test_nav.html" marginwidth="0" marginheight="0">
    <FRAMESET COLS="240,*" frameborder="0" border="0" framespacing=1" marginwidth="0" marginheight="0">
    <FRAMESET ROWS="280,*" frameborder="1" border="1" framespacing=1" marginwidth="0" marginheight="0">
    <FRAME NAME="nav" SRC="test.cgi?AUTH=$authstring&LEVEL=2">
    <FRAME NAME="options" SRC="test.cgi?AUTH=$authstring&LEVEL=4&LINK=xingnut/people_select.xing&FUNC=options_tree&LINK2=xingnut/EDC_people_view.xing&FUNC2=sds&FUNC3=search&H2=People Search
    <!--FRAME NAME="options" SRC="test.cgi?AUTH=$authstring&LEVEL=4&LINK=xingnut/import.html&FUNC=options_tree&LINK2=xingnut/view.xing&FUNC2=select" marginwidth="0" marginheight="0"-->
    </FRAMESET>
    };

  6. #6
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: problem while executing cgi script

    Hey, I assume thats only a section of your code. If not then it will definately not work. If you could post your full code I could check it all. However, heres an example to help you with what you have there...
    (Editing my post: I just remembered you said you had a problem with the HTML being displayed. To not get an error 500 I have to include Content-type: text/html\n\n but your code works fine. And the HTML frames are displayed properly. However, the pages aren't displayed within. Now this is HTML problem and is because you haven't linked to the files to be displayed inside the frame(s) correctly. So its a HTML problem you are having? Not a cgi. Are you compitent in making framesets or is this your first time? Check each frames source URL to make sure it is correct, and you have uploaded the files correctly)
    Frameset example: with 4 files located in the same directory (index.htm, one.cgi, two.cgi, three.cgi) Below is index.htm
    Code:
    
    <html>
    <head>
    <title>Title</title>
    </head>
    <frameset rows="64,25%,*">
    <frame name="top" target="_self" src="one.cgi">
    <frame name="middle" target="_self" src="two.cgi">
    <frame name="bottom" target="_self" src="three.cgi">
    
    <noframes>
    <body>
    <p>This page uses frames, but your browser doesn't support them.</p>
    </body>
    </noframes>
    
    </frameset>
    </html>
    
    Some other tips:
    1) wrap your qq in () not {}. (This is how I do it anyway)
    2) make sure you declare you are printing (CGI) using print "Content-type: text/html\n\n";
    Code:
    #! /usr/bin/perl
    # Declare content type
    print "Content-type: text/html\n\n";
    # Put your html code into the variable $html
    my $html = qq(
    <HTML>
    <HEAD>
    <TITLE>Welcome </TITLE>
    </HEAD>
    <FRAMESET COLS="*" frameborder="0" border="0" framespacing="0" marginwidth="0" marginheight="0"> 
    <FRAMESET ROWS="60,*" frameborder="0" border="0" framespacing=0" marginwidth="0" marginheight="0">
    <FRAME NAME="topnav" SRC="test.cgi?AUTH=$authstring&LEVEL=5&LINK=test_nav.html" marginwidth="0" marginheight="0">
    <FRAMESET COLS="240,*" frameborder="0" border="0" framespacing=1" marginwidth="0" marginheight="0"> 
    <FRAMESET ROWS="280,*" frameborder="1" border="1" framespacing=1" marginwidth="0" marginheight="0">
    <FRAME NAME="nav" SRC="test.cgi?AUTH=$authstring&LEVEL=2">
    <FRAME NAME="options" SRC="test.cgi?AUTH=$authstring&LEVEL=4&LINK=xingnut/people_select.xing&FUNC=options_tree&LINK2=xingnut/EDC_people_view.xing&FUNC2=sds&FUNC3=search&H2=People Search
    <!--FRAME NAME="options" SRC="test.cgi?AUTH=$authstring&LEVEL=4&LINK=xingnut/import.html&FUNC=options_tree&LINK2=xingnut/view.xing&FUNC2=select" marginwidth="0" marginheight="0"-->
    </FRAMESET>
    );
    # Print $html
    print "$html";
    Here is another example you may find useful...
    Code:
    #! /usr/bin/perl
    # Declare content type
    print "Content-type: text/html\n\n";
    # print your html
    print <<"HTML_Code";
    <HTML>
    <HEAD>
    <title>Title</title>
    </HEAD>
    <BODY>
    <p>Example text
    </BODY>
    </HTML>
    HTML_Code
    # Print a final blank statement (otherwise sometimes perl cannot find the HTML string terminator (HTML_Code)
    print "";
    Chris (let me know if you want any further help, I hope this helps).
    Last edited by xmassey; 11-07-2007 at 07:06 AM.

  7. #7
    vamshi's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    13

    Re: problem while executing cgi script

    hi thanku very much.sorry for troubling u
    i will try with u r given options and let u know the result.

  8. #8
    vamshi's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    13

    Re: problem while executing cgi script

    Hi still i am getting the problems.
    before the html code some where in the code it is printing the following i thinkbecoz of that it is not printing the rest of the code
    can u suggest please

  9. #9
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: problem while executing cgi script

    You need to post the full code, as before you only posted the HTML code you are trying to print, and thats not really Perl/CGI related. Post your entire code so I can check through it and see why there is a potential problem. Because you are carrying values in links i.e. script.cgi?name=$value&name2=$value2, there could also be problems with this. Its very difficult to see where you have gone wrong without seeing the full code, there are 100s of potential problems
    And its no trouble, I am here to help :-D
    Chris

  10. #10
    subhransu's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2007
    Location
    Pune, India
    Posts
    1

    Re: problem while executing cgi script

    Hi,

    Which OS you are using. It seems like your browser is unable to handel the cgi script hence it's opening the code. If you are using Linux then just add these few codes in your /etc/httd/conf/httpd/conf file.

    To do that be a super user and open the file by this command:

    1> vi /etc/httpd/conf/httpd.conf

    2> Add these lines at the end of the file:

    *****************************************
    <Directory /Path-to-your-directory>
    AddHandler cgi-script .cgi
    Options +Indexes +ExecCGI
    DirectoryIndex index.cgi
    AllowOverride Limit
    </Directory>
    *****************************************

    NOTE: the <path-to-your-directory> should be replaced by the directory where you have stored your code. Generally it's stored in /var/www/html

    If you are using any other OS then ask someone how to set up CGI handeler for the browser.



Tags for this Thread