in reply to secure file viewing

I wish to allow the script user to view these log files if certain pre-determined conditions are met. e.g. an error occurs.
-----------------------------------
So, I assume you want to test if the files are readable by the user and give a userfriendly error message or prompt the user for another set of files to read if it fails? Like another poster said, you would want to make sure the permissions are correct on the file itself, i.e. at the operating system level, then use the -r test on the filehandle to see if it's readable. Does that make sense?

Essentially being able to use an editor or have the same sort of functions as an editor (like vi) but not be able to break out of it to the operating system command line level. Is there a way of allowing secure file viewing from within Perl ?

===================================

Burvil * http://www.burvil.org *

Replies are listed 'Best First'.
Re^2: secure file viewing
by bowei_99 (Friar) on Feb 27, 2006 at 18:50 UTC
    So, for example, you could use the following code to test if the file is readable:

    if (-r $filename) { #do stuff here with the file } else { carp "Cannot read file $filename\n"; }

    However, it sounds like you may be essentially trying to write a text editor in perl. Why? If userfriendliness is an issue and people don't know how to use emacs/vi, there are plenty of other editors out there that are more userfriendly, like joe. If you have a GUI available, there are gui versions of vi (gvim) or emacs available.

    ===================================

    Burvil * http://www.burvil.org *