I have some code in my postwwwacct script which doesn't work, it doesn't import the sql file
shell_exec("cd /home/".$opts['user']."/public_html/sbans/sql/");
$command="mysql -u ".$opts['user']." -p".$opts['pass']." ".$opts['user']."_bans < data.sql";
shell_exec($command);
However after account creation i can manually run in ssh
cd /home/jason/public_html/sbans/sql/
mysql -u jason -pmypass jason_bans < data.sql
Which then works.
What is the problem with the php code in postwwwacct?
Sorry for re-editing your edit but the file does not have php extension
i manually call the php compiler by using
#!/usr/local/bin/php -q
解决方案
the problem is that shell_exec does cd and finishes so the command which would do the import with the sql is not found and failed.
try something like this :
$command="mysql -u ".$opts['user']." -p".$opts['pass']." ".$opts['user']."_bans < data.sql";
$output = shell_exec("cd /home/".$opts['user']."/public_html/sbans/sql/ && ".$command);
and if you want to see the result of your command just do
echo $output