The problem user_create_post.sh

s_dastjani

Verified User
Joined
Jun 16, 2014
Messages
6
hello
I want to change the config.php file
perl -pi -e 's/dbnameuser/$username_db/gi' /home/$username/domains/$domain/public_html/config.php

This command file is written
/usr/local/directadmin/scripts/custom/user_create_post.sh

Content config.php
Code:
<?php

$database = "dbnameuser";		//Datenbankname
$sqlhost = "localhost";    	//Datenbank Hostname
$sqluser = "dbnameuser";         	//Datenbank Username
$sqlpass = "dbpass";    			//Datenbank Passwort
?>

After making a account contains config.php

Code:
<?php

$database = "";		//Datenbankname
$sqlhost = "localhost";    	//Datenbank Hostname
$sqluser = "";         	//Datenbank Username
$sqlpass = "dbpass";    			//Datenbank Passwort
?>
What is the problem?
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
9,300
Location
LT, EU
Please use double quotes in your perl regex, also, you should use curly brackets to expand the variable in string:
Code:
perl -pi -e "s/dbnameuser/${username}_db/g" /home/${username}/domains/${domain}/public_html/config.php
Good luck!
 

s_dastjani

Verified User
Joined
Jun 16, 2014
Messages
6
Please use double quotes in your perl regex, also, you should use curly brackets to expand the variable in string:
Code:
perl -pi -e "s/dbnameuser/${username}_db/g" /home/${username}/domains/${domain}/public_html/config.php
Good luck!
Very Very Very Thanks
 
Top