When you say "execute through the browser", I presume you mean "send a request to a web server that happens to be running on the same machine" -- i.e. the machine you're using when you execute the script as a shell command. Or at least, you're using a network where both your shell and the web server are able to access the same directory path.

If that's not true, then that's you're problem. But if it is true, then the problem is probably due to permission settings on the directory (and on the file "test.html", if it happens to exist already when you "execute through the browser"): you probably own the directory (and the file), but the web server that executes your script "through the browser" is not a process owned by you, and that process owner would need to be granted write-access to the directory (and to the file, if it already exists).

Bear in mind that there are risks involved when granting such permissions to processes that run via a web server. Assuming that your system is managed by one or more qualified sysadmins, they would (and should) have something to say about the code you are running on your web server, when this sort of access is involved. (For example, they might advise that the writing of data files by the server be restricted to a specific path that isn't in your own home directory.)


In reply to Re: print result in text/html file-perl cgi by graff
in thread print result in text/html file-perl cgi by myfrndjk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.