473,796 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

include paths from browser and command line

code green
1,726 Recognized Expert Top Contributor
What is the best command line equivalent of $_SERVER['DOCUMENT_ROOT'].
I have recently written a number of scripts to run from an intranet
that generate reports written to CSV and XLS files that can be downloaded.
I have extended these scripts to zip and email the reports to personnel.
I am now trying to automate the scripts by calling them from Windows Scheduled Task using such CLI
Expand|Select|Wrap|Line Numbers
  1. C:\apache\xampp\php\php.exe  "C:\apache\xampp\htdocs\intranet\programs\Reports\interCoy\intercoyEntry.php"
Unfortunately they are failing on this line
[PHP]require_once '../Includes/includeFiles.ph p';[/PHP] I think because the script called is not the current working directory from a CLI.
And this doesn't seem to work either [PHP]$root = $_SERVER['DOCUMENT_ROOT'].'/';[/PHP] The scripts must still work in a browser as well as a CLI.
What is a tidy way to handle the two problems
Jan 18 '08 #1
2 1911
Atli
5,058 Recognized Expert Expert
Hi.

You could always just use a full path.
Like:
Expand|Select|Wrap|Line Numbers
  1. C:\Documents\MyWeb\MyFile.php
  2.  
Or, if your running on a Unix server
Expand|Select|Wrap|Line Numbers
  1. /usr/localhost/MyWeb/MyFile.php
  2.  
The include() function should accept an absolute path and it should solve the problem the relative path is causing in your CLI app.
Jan 18 '08 #2
code green
1,726 Recognized Expert Top Contributor
The problem with absolute paths is they are not portable across servers.
I am going to try
[PHP]$absolute_path = dirname(__FILE_ _).'/';[/PHP]
which seems to work via a browser and CLI
Jan 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1472
by: jayme | last post by:
Is there a character limit for adding additional include paths? After trying to add a path after a certain amount (about 30 paths, about 2000 characters), it removes all include paths from the command line. Anyone else get this error? Jayme
11
3657
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own rules when it comes to file paths. A lot of Microsoft installers for example, and also installers of other companies, do not work because they handle paths in the following manner:
7
4738
by: Steve M | last post by:
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the following for the command-line arguments: java -jar sforcedataloader.jar -Dsalesforce.config.dir=CONFIG_DIRECTORY They also give an example:
0
987
by: Gordon Brooks | last post by:
Does anyone know why xsd.exe chose to only support absolute paths in the schemaLocation attribute within the include element? I know that xsd.exe totally ignores the import element, and that you have to specify all of the files you want to import on the command line (so painful). Although the import element is hard to work with, at least there is a workaround. Alas, include doesn't seem to be as lucky. Does anyone have a workaround for...
5
2512
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to very carefully define the order in which paths are searched with command line options on the compiler. Both can cause problems, especially when dealing with complex software distributions. It occurs ot me that by extending the C include...
0
1197
by: Bartosz Milewski | last post by:
My resource file compiles correctly, but when I try to open it in VS, I get the error, "cannot find include file". The file in question is a "constant include". This is what it looks like in the rc file: //////////////////////////////////////////////////////////////////////////// / // // Generated from the TEXTINCLUDE 2 resource. // #include "buildoptions.h"
2
1515
by: Bill Roper | last post by:
Did you know that the #include directive when using angle brackets works substantially differently in VC7 than it did in VC6? It used to be that the reference for the additional include directories that you specify for the project started from the project directory. Now it appears to start from the directory that you're including the file from. So if you have a directory structure like this:
11
2271
by: MBS | last post by:
I am playing around with some PHP code. I want to put in an include() function so I can include existing HTML code and output it to the browser. Lo and behold PHP does not support relative paths with the include() function! (How shortsighted can you get?) Is there any way at all to use relative paths with include()? Any hacks? If I use an absolute filepath, everything is fine. But I don't want to do that--I can't do that. I want...
2
3793
by: dave6502 | last post by:
Struggling newbe here, some of my #includes work, some dont. Is it possible to list the include path ? (in BASH), I have looked at the environmental variables (loads of them) but cannot find a reference. Cheers Dave
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.