0

The following code is working on localhost xampp windows, but when i put it online godaddy shared linux hosting its not working. exec is working as i tries exec('whoami') and it outputs my account id, but the following exec command is not executing.

is there any changes i need to make it work? please guide.

$cmd = 'php file.php';

if (substr(php_uname(), 0, 7) == "Windows"){ 
    pclose(popen("start /B ". $cmd, "r"));  
} 
else { 
    exec($cmd . " > /dev/null &");   
}
ADi
  • 219
  • 1
  • 5
  • 17

1 Answers1

0

PHP exec are not supported on share hosting accounts: http://support.godaddy.com/groups/web-hosting/forum/topic/is-php-exec-available-or-executable/

Ignacio Ocampo
  • 2,693
  • 1
  • 20
  • 31
  • hi thanks for that link, so i can execute exec command but not an executable i.e .php with exec? right? bcoz when i use exec('whiami') it runs. thats trouble, now what should i do to call my file.php :( – ADi Dec 15 '13 at 00:09
  • I don't know what do you need, neither how GoDaddy assign the user for run scripts in shared hosting. But, you could use: `` – Ignacio Ocampo Dec 15 '13 at 00:13
  • well, ok. then i need some other way to run my file. maybe cURL, basically i was trying to send email in background in file.php thanks – ADi Dec 15 '13 at 00:18
  • Why not with `include` or `require`? – Ignacio Ocampo Dec 15 '13 at 00:22
  • bcoz i want it to run in background, when a user registers an email is to be sent. if i include the email takes 7sec to send and the page waits till that executes. and i have to redirect the user to profile page immediately. the user might then redirect to any page so the script should not be dependent – ADi Dec 15 '13 at 00:25
  • 1
    You could queue your emails notification in a database (or file), and configure an **cron job** to run an script periodically that check if you have pending emails. http://support.godaddy.com/help/article/3548/accessing-your-cron-job-manager-with-shared-hosting?locale=en-US&countrysite=us – Ignacio Ocampo Dec 15 '13 at 00:28
  • Thanks for that tip, will use it. but i wanted a generic system, so i could have used it anytime on some event, i.e purchase confirmation email, on product expiry. so it should be prompt. – ADi Dec 15 '13 at 00:35
  • Yep, you can do it with crontab in unix-like systems, or task in windows. And you can configure a generic queue to run each min. Regards! – Ignacio Ocampo Dec 15 '13 at 00:37