473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

include paths from browser and command line

code green
1,726 Expert 1GB
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.php';[/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 1890
Atli
5,058 Expert 4TB
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 Expert 1GB
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
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...
11
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...
7
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...
0
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...
5
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...
0
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...
2
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...
11
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...

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.