Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Oct 2005
    Posts
    35

    Default trying to call shell script with plugin

    After a lot of general rambling, the only thing I need to do with my cPanel 11 plugin is have it (or a .pm) call my shell script.

    Just to summarize my goals:
    -- the script should run as same user that is logged into cpanel.
    -- user should not need normal shell access to execute plugin.

    Any guidance appreciated.
    Simon
    Last edited by sime; 07-30-2007 at 09:39 PM. Reason: remove misleading info

  2. #2
    Member
    Join Date
    Oct 2005
    Posts
    35

    Default

    I'm going for the .pm approach now, getting my head around how this all fits together.

    foo.pm
    Code:
    #!/usr/bin/perl
    use strict;
    use Carp;
    use vars qw(@ISA @EXPORT $VERSION) ;
    require Exporter;
    require DynaLoader;
    @ISA = qw(Exporter DynaLoader) ;
    @EXPORT = qw(foo_init foo_test) ;
    $VERSION = '1.0' ;
    
    sub foo_init (
      return 1;
    )
    
    sub foo_test {
      print "HELLO WORLD";
    }
    foo_exec.html
    Code:
    <cpanel setvar="headerimg=../images/topsubdomains.gif">
    <cpanel setvar="dprefix=../">
    <cpanel Branding="include(stdheader.html)">
    <div class="body-content">
    
      <cpanel foo="test()">
    <cpanel Branding="include(stdfooter.html)">

    My current error
    Code:
    Undefined subroutine &Cpanel::emsdi::emsdi_create called at (eval 63) line 1.
    	eval 'Cpanel::emsdi::emsdi_create(@RARGS);' called at cpanel.pl line 1316
    	main::exectag('<cpanel emsdi="create()">') called at cpanel.pl line 4330
    	main::dotag(undef) called at cpanel.pl line 4219
    	main::cpanel_parseblock('SCALAR(0x8ed41a8)') called at cpanel.pl line 4173
    	main::cpanel_parse('GLOB(0x90dc210)') called at cpanel.pl line 990

  3. #3
    Member
    Join Date
    Oct 2005
    Posts
    35

    Default

    OK, that crap above is based on cpanel 10 examples (I guess). I modified my .pm file based on other pm files on the server and managed to get something to happen. Will follow up with working code.

  4. #4
    Member
    Join Date
    Oct 2005
    Posts
    35

    Default howto skeleton plugin for cp11

    OK. This is minimum chips here. Execute a shell script as the cpanel user. This doesn't do anything in particular, however it is end-to-end so that we can understand a little of what is going on.

    Step 1 - Theme

    -- Use cPanel11 with x3 theme.

    Step 2 - Plugin

    -- Follow create plugin instructions
    -- Note: Check your plugin file before installing. You might need to fix the path to your .html file. I had to change the url: line to be url:foo/foo.html

    Step 3 - cPanel page

    -- put this file in cpanel /usr/local/cpanel/base/frontend/x3/foo/foo.html
    Code:
    <cpanel setvar="headerimg=../images/topsubdomains.gif">
    <cpanel setvar="dprefix=../">
    <cpanel Branding="include(stdheader.html)">
    <div class="body-content">
    
      <cpanel foo="bar()">
    
    </div>
    <cpanel Branding="include(stdfooter.html)">
    Step 4 - cPanel module

    -- put this file in /usr/local/cpanel/Cpanel/foo.pm

    Code:
    package Cpanel::emsdi;
    use lib '/usr/local/cpanel';
    use strict;
    use Carp                 ();
    
    our $VERSION = '1.0';
    
    require 5.004;
    
    sub foo_init { return 1; }
    
    sub foo_bar {
      system ("/scripts/foo.sh");
      return 1;
    }
    Step 5 - Script to execute

    -- put this file in /scripts/foo.sh
    -- change the permissions to 755 (not sure if there is a more secure way).
    Code:
    echo "HELLO WORLD"

  5. #5
    Member
    Join Date
    Oct 2005
    Posts
    35

    Default

    Note. I have had permissions issues with calling a shell script in /scripts

    I think because my /scripts/path/to/script was not fully readable. I'm not a shell expert, I just thought I'd mention it.
    Last edited by sime; 08-02-2007 at 03:14 PM.

Similar Threads & Tags
Similar threads

  1. Server Website Builder script/plugin
    By bigXor in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 09-20-2009, 05:53 PM
  2. Call Script that Deletes Logs after Stats Run Manually?
    By thewird in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 01-12-2008, 09:11 AM
  3. Call Script that Deletes Logs after Stats Run Manually?
    By thewird in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 01-10-2008, 11:39 AM
  4. call to php file for stats script
    By stubbie in forum New User Questions
    Replies: 0
    Last Post: 11-16-2004, 07:56 AM
  5. Automating Account Creation: Shell Script? PHP Script?
    By RangerWest in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 07-13-2003, 10:24 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube