[pmwiki-users] New Recipe: WikiSh

Chris Cox ccox at airmail.net
Thu Jan 31 13:29:12 CST 2008


We use one we call "shellout".  It merely allows you to
execute a shell command.  The security is that the
program has to be in /usr/local/sbin (which we'll assume
is root controlled).

Usage:

(:shellout cmd=mycustomcommand parms="arguments to pass":)


Markup('shellout','fulltext',
        "/\\(:shellout[         ]*(.*?):\\)/e",
        "shellout('$1')");

function shellout($opts) {
        $args = ParseArgs($opts);
        $shelloutcmd="GET='".implode(",",$_GET)."' POST='".implode(",",$_POST)."' /usr/local/sbin/" . basename($args['cmd']) . " " . $args['parms'];
        $shelloutoutput = shell_exec($shelloutcmd);
        return $shelloutoutput;
}


Peter & Melodye Bowers wrote:
> I've just put a very-alpha recipe out there called WikiSh.  It's working in
> the test cases I've thrown at it, but no doubt there is significant testing
> remaining -- please let me know when you run into problems with it.
> 
> It was started at the same time as Text Extract, but with a different
> purpose and direction in implementation.  However, initial code and etc. all
> come from Hans...
> 
> The problem below (returning lines from one text pattern to another) would
> be handled in this manner:
> 
> {(sed -n '/TextPatternA/,/TextPatternB/p' file)}
> 
> You can also specify other commands to the sed command using multiple
> applications of the -e option as follows:
> 
> {(sed -n -e '1,2p' -e '/TextPatternA/,/TextPatternB/p' -e
> 's/searchfor/replace/g' file)}
> 
> (This would return the first 2 lines and the lines between TextPatternA and
> TextPatternB (inclusive) and also do a search/replace.)
> 
> The other commands contained within WikiSh include wc (-w=wordcount which
> also does -l=linecount and -c=charcount), head (returns the top -n=n lines
> from a file), tail (same for the end of the file), cat (returns all lines),
> etc.
> 
> This is a beginning - lots more to go, but I thought since it answered this
> specific need here it might be appropriate to put it out there...
> 
> -Peter
> 
>> -----Original Message-----
>> From: pmwiki-users-bounces at pmichaud.com [mailto:pmwiki-users-
>> bounces at pmichaud.com] On Behalf Of Graham Archer
>> Sent: Wednesday, January 30, 2008 10:29 PM
>> To: Hans
>> Cc: pmwiki-users at pmichaud.com
>> Subject: Re: [pmwiki-users] New Recipe: Text Extract
>>
>>
>> Hi Hans,
>>
>> the problem with a nice recipe is sometimes the Customers get a bit
>> greedy - please tell me if I am doing this in this instance.....
>>
>> I was wondering if your recipe could be extended to:
>>
>>   extract from #TextPatternA# to "TextPatternB"
>>
>> Reason:   I use (:include pagename #from#to:) at the moment to bring
>> content from another page. Problem with this is
>> the RSS for the host page doesn't trigger even thou the included page
>> has changed since the host hasn't been re-written.
>>
>> A nice feature with your recipe is that it writes to the page  and
>> causes the RSS event.  So if the extract could go
>> #from #to it would be a nice feature!
>>
>> Thanks
>>
>> Graham
>>
>>
>>
>>
>> _______________________________________________
>> pmwiki-users mailing list
>> pmwiki-users at pmichaud.com
>> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
> 
> 
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
> 
> 



More information about the pmwiki-users mailing list