Results 1 to 2 of 2

Thread: Auto creation of cpanel accounts through command line

  1. #1
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Jul 2003
    Posts
    130

    Default Auto creation of cpanel accounts through command line

    Hello,

    For the past year, we've had customer accounts and noc accounts created from within a cpanel VM automatically through a cron after the VM is provisioned (hyper-v). This worked up until 2 weeks ago when I went into our VM templates and upgraded all of their cPanels as well as the kernel. Now, all functions of the cron job work EXCEPT for the account creation. This is how the creation was being done -

    USERNAME=$USERNAME
    DOMAIN=$DOMAIN

    ## Create a new Account

    echo '#!/usr/bin/expect -f' > /root/expect
    echo "spawn /scripts/createacct "$DOMAIN" "$USERNAME" 12345678" >> /root/expect
    echo "expect ok?" >> /root/expect
    echo 'send "y\n"' >> /root/expect
    echo "interact" >> /root/expect
    chmod 755 /root/expect
    /root/expect &

    sleep 10

    This works if I just type in the commands in the VM. However, if it is being executed by a cron, it will not work (it used to).

    There is really no way for me to use the API unless I heavily modify our processes which would take a great deal of time. I really need to be able to create an account through command line. And support has told me there is no way but using the API which I find very hard to believe. A few years ago, there was an environment variable we could set so it wouldn't ask "This ok?" but that is no longer an option anymore.

    Anyone know of a work around.
    Arvixe - Freedom of the web at your fingertips

  2. #2
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    7,611
    cPanel/WHM Access Level

    Root Administrator

    Default Re: Auto creation of cpanel accounts through command line

    You can pipe yes as that is a Linux command to any script that you run:

    Code:
    yes | /scripts/createacct happytime.foo happytf 12346666
    If you do the above, it pipes yes when it runs and will create the user without having to input yes. Re-write your script to pipe yea like this and it should work. I just tested it and it doesn't even then ask me during the creation (I'm just pasting a small output as it creates the full account and goes on multiple lines afterward):

    Code:
    # yes | /scripts/createacct happytime.foo happytf 12346666
    +===================================+
    | New Account Info                  |
    +===================================+
    | Domain: happytime.foo
    | UserName: happytf
    | PassWord: 12346666
    +===================================+
    
    Checking input data......Done
    WWWAcct 12.5.0 (c) 2012 cPanel, Inc.......Done
    Running pre creation script (/usr/local/cpanel/scripts/prewwwacct)......Done
    Adding User......Done
    Copying skel files from /root/cpanel3-skel/ to /home/happytf/......Done
    Adding Entries to httpd.conf......Done
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Technical Analyst III, Forums Specialist, cPanel Tech Support

    Submit a ticket | Check an existing ticket

Similar Threads

  1. Auto-update via -autoupdate command line (TF2)
    By thejim in forum cPGS Discussions
    Replies: 2
    Last Post: 08-08-2011, 11:14 AM
  2. Creating e-mail accounts through command line
    By romerojnr in forum New User Questions
    Replies: 2
    Last Post: 05-27-2011, 12:43 PM
  3. Upgrade/Downgrade accounts from command line
    By FrankLaszlo in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 08-03-2010, 10:26 AM
  4. What is the command to restart cpanel via the command line?
    By AbeFroman in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 07-29-2004, 03:24 PM