Was this page helpful?

Shell Output

    This extension is designed to execute shell commands and display their output on DekiWiki. This extension is based onVivieny's Deki_Extension_for_PHP and needs at least DekiWiki 8.05. If you have any question, please open a new thread on the forum and send me a private message with the post link.

    INSTALLATION

    1. Create two new folder /var/www/deki-hayes/config/extensions and /exec
    2. Copy to /var/www/deki-hayes/config/extensions the files DekiExt.php and IXR_Library.inc.php.txt as described at Vivieny's Deki_Extension_for_PHP
    3. Copy to /var/www/deki-hayes/config/extensions the attached files exec.php and shell.php
    4. Take ownership of all new files
      1. chown -R www-data:www-data  /var/www/deki-hayes/config/*
      2. chown -R www-data:www-data  /exec
    5. Go to Service managmenent in the Control Panel of your wiki
    6. Under Add Service, click on Remote, and configure:
      1. Type = Extension
      2. Description = Shell Output Extension
      3. URI = http://localhost/config/extensions/shell.php
      4. Status = Enabled
    7. Click on add service
    8. This extension will only execute executable files found at /exec folder. So you must create there any scripts you need to execute or create symlinks to any executable you want. For example:

    ln -s /bin/ps /exec/ps

             

    FUNCTIONS

    shell.exec(program:str):xml

    This function will execute the parameter program and display the command output on the wiki page. For example:

    {{ shell.exec("ps") }}

    will display something similar to

    PID TTY          TIME CMD
    8523 ?        00:01:04 mono
    14984 ?        00:00:00 apache2
    14987 ?        00:00:00 apache2
    14988 ?        00:00:00 apache2
    14989 ?        00:00:00 apache2
    15526 ?        00:00:00 apache2
    15527 ?        00:00:00 apache2
    15528 ?        00:00:00 apache2
    15529 ?        00:00:00 apache2
    15530 ?        00:00:00 apache2
    15531 ?        00:00:00 apache2
    15911 ?        00:00:00 ps

    execExternal(program:str):xml

    This function will display a link that will open a new window display the command output . For example:

    {{ shell.execExternal("ps") }}

    will display something similar to

    ps   
    

          

    Was this page helpful?
    Tag page

    Files 3

    FileVersionSizeModified 
    • v1
    • 304 bytes
    • 13:38, 8 May 2008
    •  
    Viewing 1 of 1 comments: view all
    I believe this extension will be really poewrful for us - anyone can write a shell script, python or even C program and so long as it exits quickly and writes to stdout, it can be called from a deki page. Fantastic!
    I had a real fight to get this extension to go, however, because our server's PHP environment doesn't have xmlwriter available. Eventually I resorted to rewriting DekiExt.php so that it wrote the XML directly. I've uploaded my version to this page if anyone wants to try it.
    I also had to modify the uri in the shell.php execFunction() code, replacing 'localhost' with our server's name, as we have a rewrite rule set up. I was getting 'HTTP 301 Page moved permanently' errors.
    Posted 17:21, 15 Dec 2009
    Viewing 1 of 1 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by