tptompkins

Registered
Oct 31, 2013
2
0
1
cPanel Access Level
Root Administrator
Hello,

I've been working on this a couple of days and can't seem to get this script to run on account creation in WHM. WHM says that it's running the file in the account creation output, but I'm not finding any evidence that the file is running.

I'm running WHM 11.38.2 (build 12)

Here's what I've tried:

1) I saved the postwwwacct file to: /usr/local/cpanel/scripts/
2) I set the execution bits with: chmod +x postwwwacct
3) Nothing is being written to the error log in: /usr/local/cpanel/logs/error_log or /usr/local/cpanel/logs/error_log_tommy
4) I've tried both #!/usr/local/bin/php and #!/usr/bin/php at the top of the file and neither seem to work.
5) I've tried ini_set('display_errors',1); and ini_set('display_errors',0); and that doesn't seem to make any difference.

Here's my code:

PHP:
#!/usr/local/bin/php
<?php
ini_set('error_log','/usr/local/cpanel/logs/error_log_tommy');
ini_set('display_errors',1);
error_log( "Hello, this is a test error!" );
Any ideas for other things that I can try?

Your help is very much appreciated. Thank you,

Tommy
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello :)

Could you elaborate on what actions you would like to implement after account creation? Are you trying to set specific PHP values for individual accounts?

Thank you.
 

tptompkins

Registered
Oct 31, 2013
2
0
1
cPanel Access Level
Root Administrator
Thanks for the quick reply! Just after I posted here I actually figured it out. The postwwwacct file that I uploaded had Windows end of line characters so I had to convert it to Unix encoding. After that it ran and logged my test error to my log file correctly on account creation.

After I got it working, I was able to use the xml api to create a new db, db user, assign user privileges, and create a cron job from the script. All that works great.

Now I'm trying to figure out how to update the email for the cron jobs on a user's account using the xml api. Any tips on how to do that?

Thanks!

Tommy
 

companyjuice

Registered
Feb 18, 2014
1
0
1
cPanel Access Level
Root Administrator
Thanks Tommy! I was also having the same issue, and your solution to "convert it to Unix encoding" because the file you "uploaded had Windows end-of-line characters" (EOL) that weren't being handled by the Unix/Linux processor. Basically, Windows uses CRLF and Unix/Linux uses CR. For other readers at this point, here is the solution for me to change/convert my Windows EOL files to Unix EOL files us the command "tr":

Unix/Linux Command:
tr -d '\015' < DOS-file > UNIX-file

Example:
tr -d '\015' < /home/user/test/postwwwacct > /usr/local/cpanel/scripts/postwwwacct

Note that the name DOS-file is different from the name UNIX-file; if you try to use the same filename twice (overwrite the file), you will end up with no data in the original file.