Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Perl regular expression rules

by wellmje (Initiate)
on Dec 06, 2012 at 00:27 UTC ( #1007438=perlquestion: print w/replies, xml ) Need Help??
wellmje has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am looking for a way to validate that this use of regular expressions will match all and any commands except SU on a Red Hat Linux server when following Perl rules


Any assistance or direction would be appreciated. I know there are many other ways to achieve the same goal but I am being told that this should work. Thank You in advance!

Replies are listed 'Best First'.
Re: Perl regular expression rules
by Crackers2 (Parson) on Dec 06, 2012 at 01:58 UTC

    You may want to give more details about what you're trying to accomplish, because...

    [user@host]$ ll /bin/su -rwsr-xr-x 1 root root 30148 Jul 21 19:54 /bin/su [user@host]$ ln -s /bin/su notsu [user@host]$ ./notsu Password: [root@host]#

    So if you're trying to use this to prevent people from running su it's probably not a good idea.

Re: Perl regular expression rules
by ww (Archbishop) on Dec 06, 2012 at 00:39 UTC
    The best way to validate your regex is to read the docs re regexen; perlre, perlretut, etc (and there's lots of etc inside perldoc, too) and use the knowledge acquired to refine your ability to understand the regex.

    Second best, perhaps? Seek out a regex explanation utility of the sort frequently mentioned here.

    Next best, try it. Test (brute force) a substantial subset or all the commands you're likely to use, in a dry run setting like:

    #pseudocode my @commands=qw(ls rm rd cat....); for $command(@commands) { if ($command =~ /(your regex here)/ ) { say "regex matched $command"; } else { say "Oops! $command slipped by"; } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1007438]
Approved by LanX
[Corion]: I'm coming to the slow/late realization that Linux is far better/convenient for rooting/modifying Android devices than Windows, as there is much less baggage interfering with adb when you want to send new firmware to a device...
[Corion]: But I think I missed the big sell-off of Amazon Kindle Fire 7 (2015) devices, as they're not for sale anymore and the newer devices don't have a replacement Android yet. But at EUR 40 per device, they were quite OK
[Corion]: So now I am on the lookout for other tablets in that price range or lower, to repurpose them for whatever ;) One is used by my sister as clock in a photoframe, and this one will be used by my father as display device to entertain unruly kids
[marto]: yes, trying to do anything other than sideload to android via windows has always been more effort than linux

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2018-05-23 09:06 GMT
Find Nodes?
    Voting Booth?