arianhojat Posted June 14, 2007 Share Posted June 14, 2007 Hello all, Had some trouble and kinda stumped on why php behaves this way: In Windows I have a Scheduled Task to run emailer.bat... By the way, for future reference... emailer.bat is not in the web root, E:\Intranet\, it is in E:\batches\. In emailer.bat is the command to run php script on command line: php -a E:\Intranet\HelpDesk\techReqEmailer.php In techReqEmailer.php, is the line require("../phpmailer/class.phpmailer.php"); //or require("/phpmailer/class.phpmailer.php"); doesnt make difference both fail Basically it looks for phpmailer class one parent up in the E:\Intranet\phpmailer\ folder. If I goto http://intranetServer/HelpDesk/techReqEmailer.php, it knows how to find the phpmailer class and sends emails since it knows to look up one level to find phpmailer. However when this file is run from a batch file, it doesnt know how and gives a standard php error for not finding the required class. The only way i got passed this was to put the batch file also in the E:\Intranet\HelpDesk\ folder, AND make it look relative for phpmailer... require("phpmailer/class.phpmailer.php"); (so bascially i have 2 copies of phpmailer now, one folder in main web root for other web scripts that send emails, and one in this folder for the batch script, errr, seems annoying to duplicate the folder)... Is there anyway i can have the batch file placed wherever i want, and leave alone the phpmailer class and techReqEmailer.php will know where to look for it whether its called via web or batch script? it should look for include_path 1st, then based on current directory, which is what i was hoping. but batch file thinsk curretn directory is where the batch is, and not where the php file is. I assumed the php file would only 'know' about itself, and didnt matter if batch file called it. But apprently it does? Thanks for any tips and clarification , Arian Quote Link to comment https://forums.phpfreaks.com/topic/55638-problems-with-requireinclude-when-running-windows-batch-file-php-script/ Share on other sites More sharing options...
arianhojat Posted June 15, 2007 Author Share Posted June 15, 2007 bump. summary: anyone got an idea why the batch looks via its directory and not the scripts directory? Quote Link to comment https://forums.phpfreaks.com/topic/55638-problems-with-requireinclude-when-running-windows-batch-file-php-script/#findComment-275585 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.