Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: CGI script to output data as CSV

by Anonymous Monk
on Jul 09, 2015 at 04:58 UTC ( [id://1133875]=note: print w/replies, xml ) Need Help??


in reply to Re: CGI script to output data as CSV
in thread CGI script to output data as CSV

Thanks for the reply. I think you're right, I need to change permissions...but I'm a bit unsure how to do that right of now. I've accessed the server via CLI on my mac and tried to use "chmod 777 on my cgi-bin folder,and it said it was changed, but I'm still not able to access data. I don't get an error, just redirected to the main domain page.

Replies are listed 'Best First'.
Re^3: CGI script to output data as CSV
by afoken (Chancellor) on Jul 09, 2015 at 07:37 UTC
    chmod 777 on my cgi-bin folder

    Are you aware of what that command does? You just have made your cgi-bin directory writeable for every user on that machine!

    The three digits following chmod encode permissions for the owner ("user"), the group ("group"), and all other users ("others", "world"), in this order. Each digit has the same meaning: 4 means reading allowed ("read", "r"), 2 means writing allowed ("write", "w"), 1 means execute file / crossing directory allowed ("execute", "x"). 0 means nothing allowed. Other digits are just sums, 7 means full permissings, 5 just read and execute/cross, 6 means read and write, but no execute. 3 (write and execute) is rarely used.

    Common combinations are:

    400, r--------
    read-only, only for the user. No permissions for group and world. Common for files that are secret (e.g. passwords) and should not accidentally overwritten.
    600, rw-------
    read-write. Like 400, but writeable.
    700, rwx------
    rwx for the user. A private, writeable program, e.g. a script with sensitive data. For directories, a private directory that nobody else may list, change, or even enter.
    644, rw-r--r--
    readable for everyone, but writeable only for the user. The common mode for all kinds of non-executable files.
    755, rwxr-xr-x
    like 644, but with executable flag set. The common mode for executable files and directories that may be listed by others.
    711, rwx--x--x
    full access for the owner, but only executable permissions for group and others. Useful for binary executables (not scripts) that can be run by everyone, but nobody except the owner may read or write it. For directories, this allows to cross the directory, but non-owner users can't list or change them.
    666, rw-rw-rw-
    Everybody may read or write, but not execute. Scratchpad. Don't trust such files.
    777, rwxrwxrwx
    "Stupid mode", everybody may read, write, and execute. For directories, everybody may list and write to that directory. Except for the temporary directories /tmp and /var/tmp, this is almost always wrong. You want 755. (/tmp and /var/tmp also have the sticky bit set, but that's a different story.)
    640, 750, 710, 660, 770
    as above, but limited to user and group. Others don't have access.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      1 means execute file / crossing directory allowed ("execute", "x").

      Boundaries? Like if its a link to a different mount?

        Boundaries? Like if its a link to a different mount?

        No:

        >mkdir foo >ls -ld foo drwxr-xr-x 2 alex users 40 Jul 9 10:44 foo/ >mkdir foo/bar >ls -l foo total 0 drwxr-xr-x 2 alex users 40 Jul 9 10:44 bar/ >chmod 000 foo >ls -ld foo d--------- 3 alex users 60 Jul 9 10:44 foo/ >ls foo /bin/ls: cannot open directory foo: Permission denied >cd foo -bash: cd: foo: Permission denied >chmod 100 foo >ls foo /bin/ls: cannot open directory foo: Permission denied >cd foo >pwd /tmp/foo >ls /bin/ls: cannot open directory .: Permission denied >cd bar >pwd /tmp/foo/bar >cd /tmp >chmod 400 foo >ls -ld foo dr-------- 3 alex users 60 Jul 9 10:44 foo/ >cd foo -bash: cd: foo: Permission denied >cd foo/bar -bash: cd: foo/bar: Permission denied >

        To read the contents of a directory (/bin/ls, opendir/readdir), you need read permissions, the "r" bit, 4 in the usual octal numbers.

        To "cross" the directory, e.g. make it the current directory or just use it in a path, you need execute permissions, the "x" bit, 1 in the usual octal numbers.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: CGI script to output data as CSV
by Anonymous Monk on Jul 09, 2015 at 06:48 UTC

    "chmod 777 on my cgi-bin folder"

    Um, thats a bit premature, you don't know what the issue is yet

    but I'm still not able to access data. I don't get an error, just redirected to the main domain page.

    That probably means the script did not run at all -- so what did the log say?

    Why do you think the url you're accessing is supposed to run your script?

      I actually did chmod 755. Hopefully that's not as bad? I'm using this to collect data from an iOS app. I'll run through the app, input some data. Then go to check if the data has been collected via "serveraddress/participant_id_data.csv" and it just redirects me to the server homepage. Does that mean the script is not running at all? On my app side it says data has been successfully saved. I'm a little perplexed as to what might be wrong. I'm still a bit of a newbie to all this...

        I actually did chmod 755. Hopefully that's not as bad? I'm using this to collect data from an iOS app. I'll run through the app, input some data. Then go to check if the data has been collected via "serveraddress/participant_id_data.csv" and it just redirects me to the server homepage. Does that mean the script is not running at all? On my app side it says data has been successfully saved. I'm a little perplexed as to what might be wrong. I'm still a bit of a newbie to all this...

        Why would visiting "serveraddress/participant_id_data.csv" run a cgi script?

        For example when you visit perlmonks, its index.pl that runs. This link calls index.pl, as does this one, because thats how perlmonks apache is configured.

        For a server to serve participant_id_data.csv it has to be configured to do so

        For "serveraddress/participant_id_data.csv" to run a cgi script it has to be configured to do so.

        If your server simply redirects, that probably means it doesn't recognize participant_id_data.csv as a valid resource, it has no idea you want it to run a cgi script or serve some file

        Also, why aren't you checking your server logs? They answer everything

        FYI

        Every perl/CGI problem can be solved if you work through these checklists, when you find a problem on the list, use a solution from the list, when you find a problem not on the list (rare), post the error message and problem description here

        CGI Help Guide, Troubleshooting Perl CGI scripts, CGI to mod_perl Porting. mod_perl Coding guidelines.. cgi101 brian's Guide to Solving Any Perl Problem, CGI Help Guide , Troubleshooting Perl CGI scripts ... More generic advice :) On debugging, verify everything, talk to teddybear ... checklists and more

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-20 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found