Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi there , I am just learning how to use CGI and I have a small question. After I excute my script, an output file is being generated on my working directory. What I need to do is to be able to click at somthing from the HTML page and be able to open the file without browsing manually to it. So I did somthing like this at the bottom of my scripts :
print "<A HREF=\"C:/Documents and Settings/mqa/scr/tcl/outputFile\">Cl +ick Here To View Output</A>\n"; exit(0);
Where the outputFile is the one get generated and I need to open. So I see the click and when I do click on it , nothing happens and no errors get generated. Do I need to use notepad or some other txt editor to open it ? if yes , How do I do that ? Please excuse me , I am just new to the whole HTML stuff . thanks

Replies are listed 'Best First'.
Re: CGI HREF
by ww (Archbishop) on Dec 04, 2007 at 22:12 UTC
    Are you sure your generated file has content?
    Check the size; try to open it with notepad.

    What type of file are you generating?
    Text, html, xml, cvs or ....?

    When you say "new to CGI" do you mean CGI.pm?
    If not, what?

    You "see the click" where?
    In your command prompt window? In a browser? Where?

    What's the script that's doing the generating look like?
    We're more likely to be able to help if we know more about your problem, including the answers to these questions and your script, itself.

    You may also find considerable help in viewing Ovid's [http://users.easystreet.com/ovid/cgi_course/|on-line tutorial and the author's own site.

Re: CGI HREF
by igelkott (Priest) on Dec 04, 2007 at 22:18 UTC
    Using Firefox perhaps? The standard security practice is to disregard links to your local filesystem. Internet Explorer (assuming windows) lacks this safety feature so, if this was the only problem, the link will work there.

    Firefox can be set to ignore this feature on a global (yuck) or site by site basis (in recent versions, at least).

      your href is a link to the local filesystem, which is typically not served up by the web server..otherwise anybody could come in via www and download (or even change) anything anywhere.
      the web server serves up files etc from a specific directory designated as the Document Root for the web service. This security mechanism may or may not come into play when you're accessing the document on the same machine that has the www service.
      Also, browser mime types come into play, as once you can get to the file, the browser will be opening it.
      also...check your web server error log.
      the hardest line to type correctly is: stty erase ^H
Re: CGI HREF
by Gangabass (Vicar) on Dec 05, 2007 at 02:38 UTC

    Try this code (for Firefox):

    print "<A HREF=\"file:///C:/Documents%20and%20Settings/mqa/scr/tcl/out +putFile\">Click Here To View Output</A>";

    or this (for Opera):

    print "<A HREF=\"file://localhost/C:/Documents%20and%20Settings/mqa/sc +r/tcl/outputFile\">Click Here To View Output</A>";

    But as said before browsers don't allow to open local files to sites. Unless this website is in Local security zone.