Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Opening files to write in browser returns Permission denied

by huck (Parson)
on May 03, 2017 at 00:19 UTC ( #1189376=note: print w/replies, xml ) Need Help??


in reply to Opening files to write in browser returns Permission denied

a script running in my browser

Do you mean a script running on your server as cgi called by the browser?

Or are you talking about some java/javascript actuality running in the browser

For as far as i know, perl doesnt run in a broswer

In the first case i would first wonder what userid/group the cgi is running under. You may be trying to write somewhere that your userid has access to, but the web-server does not

In the second case, i would kinda suggest you just give up. There is supposed to be a very restricted environment presented by the browser called "the sandbox" and most activity outside that is curtailed. A quick google search has again suggested that writing files under the browser is not easy, one suggested sending what you wanted to write back over tcpip to a server process/cgi that sends it back as a downloadable file the user can then accept.

  • Comment on Re: Opening files to write in browser returns Permission denied

Replies are listed 'Best First'.
Re^2: Opening files to write in browser returns Permission denied
by Lady_Aleena (Curate) on May 03, 2017 at 00:47 UTC

    I am talking about a script, one called sitemap.pl, that opens in my browser and displays html content. At the end of the script, I have it write a list created in the script to a file. sitemap.pl, opened in the browser, can not write to sitemap.txt in the same directory as sitemap.pl unless the text file's permissions are set to 666.

    So, from what I am gathering here, I have to set write files to 666 so that the output from scripts running in the browser can write to them.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena

      How do you open sitemap.pl in your browser?

      You may find it of interest to run this

      my $user = `whoami`; chomp $user; my $groups = `groups $user`; chomp $groups; print "<br>I am running as $user in groups $groups\n";
      I suspect that the user you get back is not what you expected. I also suspect it is the last 6 in 666 that is fixing your problem. You are setting up a file that anyone can write into. Knowing what groups you are in and the perl process is running you may be able to determine what groups you may have in common. Setting that file (or directory) to be a member of that common group may mean you dont need to let anyone write to that file, but limit it to only userids in that common group.

        I did as you specified and was surprised by the result. I will have to dig into apache2 to see how can make my "localhost" local to me. Thank you huck!

        No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
        Lady Aleena
        Whether it is the first, the second, or the third... That seems to work.

        P.S. Would it be better to set the file permissions to 777? Why does evil win here?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1189376]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2019-05-23 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (140 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!