i'm trying to re-use scripts, typically called via a browser, in the php
cli. the cli calls are made through cron jobs. i'm hitting some unknowns as
to path info. here's the error i'm getting thus far:
"PHP Warning: require_once(../../../../../../site.cfg.php): failed to open
stream: No such file or directory in
/var/www/html/dev/admin/cli/import.repair.orders.cli.php on line 5"
i'm executing the cli from:
/home/me/www/dev/admin (www is a symlink to /var/www/html/)
first, what is the current directory for php cli when executed from a cron?
second, will i need to adjust the current directory or anything else so that
other included/required files (normally accessed via a browser) are
referenced correctly?
thanks for your input.
=======================
here's the pertanent code...
my include path is:
/usr/share/pear
in that directory i have a file named relative.path.php. its purpose is to
abstract/simplify inclusionary script paths. it looks like:
<?
$parsedUri = dirname($_SERVER['PHP_SELF']);
$parsedUri .= substr($parsedUri, -1) != '/' ? '/' : '';
$relativeUri = str_replace('/', '', $parsedUri);
$relativePath = strlen($parsedUri) - strlen($relativeUri) - 1;
if ($relativePath < 0){ $relativePath = 0; }
$relativePath = str_repeat('../', $relativePath);
if (!$relativePath){ $relativePath = './'; }
?>
i'm wrapping the files i'm trying to re-use via cli in code similar to (call
it, import.financials.cli.php):
#!/usr/bin/php -q
<?
$cli = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$rootDirectory . 'admin/import.financials.php';
?>
the site.cfg.php creates a singleton class 'site' and $rootDirectory would
be the absolute path to the web root. import.financials.php begins like
this:
<?
if (!$cli)
{
$pageTitle = 'Import Financials';
$fullHeader = false;
$securityEnabled = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$includeDirectory . 'head.inc.php';
}
?>
however, as the error indicated, we never get to this point since
import.financials.cli.php cannot find site.cfg.php (as it normally would if
called from a browser).
tia,
me 4 4314
On 18 Mai, 18:51, "Steve" <no....@example.comwrote:
i'm trying to re-use scripts, typically called via a browser, in the php
cli. the cli calls are made through cron jobs. i'm hitting some unknowns as
to path info. here's the error i'm getting thus far:
"PHP Warning: require_once(../../../../../../site.cfg.php): failed to open
stream: No such file or directory in
/var/www/html/dev/admin/cli/import.repair.orders.cli.php on line 5"
i'm executing the cli from:
/home/me/www/dev/admin (www is a symlink to /var/www/html/)
first, what is the current directory for php cli when executed from a cron?
second, will i need to adjust the current directory or anything else so that
other included/required files (normally accessed via a browser) are
referenced correctly?
thanks for your input.
=======================
here's the pertanent code...
my include path is:
/usr/share/pear
in that directory i have a file named relative.path.php. its purpose is to
abstract/simplify inclusionary script paths. it looks like:
<?
$parsedUri = dirname($_SERVER['PHP_SELF']);
$parsedUri .= substr($parsedUri, -1) != '/' ? '/' : '';
$relativeUri = str_replace('/', '', $parsedUri);
$relativePath = strlen($parsedUri) - strlen($relativeUri) - 1;
if ($relativePath < 0){ $relativePath = 0; }
$relativePath = str_repeat('../', $relativePath);
if (!$relativePath){ $relativePath = './'; }
?>
i'm wrapping the files i'm trying to re-use via cli in code similar to (call
it, import.financials.cli.php):
#!/usr/bin/php -q
<?
$cli = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$rootDirectory . 'admin/import.financials.php';
?>
the site.cfg.php creates a singleton class 'site' and $rootDirectory would
be the absolute path to the web root. import.financials.php begins like
this:
<?
if (!$cli)
{
$pageTitle = 'Import Financials';
$fullHeader = false;
$securityEnabled = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$includeDirectory . 'head.inc.php';}
?>
however, as the error indicated, we never get to this point since
import.financials.cli.php cannot find site.cfg.php (as it normally would if
called from a browser).
tia,
me
Hi Steve,
the superglobal $_SERVER exists only, if PHP is running as a module or
cgi (webserver). Use __FILE__ instead of $_SERVER['PHP_SELF'].
Or you can put a workaround in your cli wrapper, by setting
$_SERVER['PHP_SELF'] or other needed $_SERVER[*] variables.
purcaholic
On May 18, 1:54 pm, purcaholic <purcaho...@googlemail.comwrote:
On 18 Mai, 18:51, "Steve" <no....@example.comwrote:
i'm trying to re-use scripts, typically called via a browser, in the php
cli. the cli calls are made through cron jobs. i'm hitting some unknowns as
to path info. here's the error i'm getting thus far:
"PHP Warning: require_once(../../../../../../site.cfg.php): failed to open
stream: No such file or directory in
/var/www/html/dev/admin/cli/import.repair.orders.cli.php on line 5"
i'm executing the cli from:
/home/me/www/dev/admin (www is a symlink to /var/www/html/)
first, what is the current directory for php cli when executed from a cron?
second, will i need to adjust the current directory or anything else so that
other included/required files (normally accessed via a browser) are
referenced correctly?
thanks for your input.
=======================
here's the pertanent code...
my include path is:
/usr/share/pear
in that directory i have a file named relative.path.php. its purpose is to
abstract/simplify inclusionary script paths. it looks like:
<?
$parsedUri = dirname($_SERVER['PHP_SELF']);
$parsedUri .= substr($parsedUri, -1) != '/' ? '/' : '';
$relativeUri = str_replace('/', '', $parsedUri);
$relativePath = strlen($parsedUri) - strlen($relativeUri) - 1;
if ($relativePath < 0){ $relativePath = 0; }
$relativePath = str_repeat('../', $relativePath);
if (!$relativePath){ $relativePath = './'; }
?>
i'm wrapping the files i'm trying to re-use via cli in code similar to (call
it, import.financials.cli.php):
#!/usr/bin/php -q
<?
$cli = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$rootDirectory . 'admin/import.financials.php';
?>
the site.cfg.php creates a singleton class 'site' and $rootDirectory would
be the absolute path to the web root. import.financials.php begins like
this:
<?
if (!$cli)
{
$pageTitle = 'Import Financials';
$fullHeader = false;
$securityEnabled = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$includeDirectory . 'head.inc.php';}
?>
however, as the error indicated, we never get to this point since
import.financials.cli.php cannot find site.cfg.php (as it normally would if
called from a browser).
tia,
me
Hi Steve,
the superglobal $_SERVER exists only, if PHP is running as a module or
cgi (webserver). Use __FILE__ instead of $_SERVER['PHP_SELF'].
Or you can put a workaround in your cli wrapper, by setting
$_SERVER['PHP_SELF'] or other needed $_SERVER[*] variables.
purcaholic
I beg to differ. Running print_r($_SERVER) from the CLI outputs all
sorts of stuff -- including PHP_SELF.
On 18 Mai, 20:02, ZeldorBlat <zeldorb...@gmail.comwrote:
On May 18, 1:54 pm, purcaholic <purcaho...@googlemail.comwrote:
On 18 Mai, 18:51, "Steve" <no....@example.comwrote:
i'm trying to re-use scripts, typically called via a browser, in the php
cli. the cli calls are made through cron jobs. i'm hitting some unknowns as
to path info. here's the error i'm getting thus far:
"PHP Warning: require_once(../../../../../../site.cfg.php): failed to open
stream: No such file or directory in
/var/www/html/dev/admin/cli/import.repair.orders.cli.php on line 5"
i'm executing the cli from:
/home/me/www/dev/admin (www is a symlink to /var/www/html/)
first, what is the current directory for php cli when executed from a cron?
second, will i need to adjust the current directory or anything else so that
other included/required files (normally accessed via a browser) are
referenced correctly?
thanks for your input.
=======================
here's the pertanent code...
my include path is:
/usr/share/pear
in that directory i have a file named relative.path.php. its purpose is to
abstract/simplify inclusionary script paths. it looks like:
<?
$parsedUri = dirname($_SERVER['PHP_SELF']);
$parsedUri .= substr($parsedUri, -1) != '/' ? '/' : '';
$relativeUri = str_replace('/', '', $parsedUri);
$relativePath = strlen($parsedUri) - strlen($relativeUri) - 1;
if ($relativePath < 0){ $relativePath = 0; }
$relativePath = str_repeat('../', $relativePath);
if (!$relativePath){ $relativePath = './'; }
?>
i'm wrapping the files i'm trying to re-use via cli in code similar to (call
it, import.financials.cli.php):
#!/usr/bin/php -q
<?
$cli = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$rootDirectory . 'admin/import.financials.php';
?>
the site.cfg.php creates a singleton class 'site' and $rootDirectory would
be the absolute path to the web root. import.financials.php begins like
this:
<?
if (!$cli)
{
$pageTitle = 'Import Financials';
$fullHeader = false;
$securityEnabled = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once site::$includeDirectory . 'head.inc.php';}
?>
however, as the error indicated, we never get to this point since
import.financials.cli.php cannot find site.cfg.php (as it normally would if
called from a browser).
tia,
me
Hi Steve,
the superglobal $_SERVER exists only, if PHP is running as a module or
cgi (webserver). Use __FILE__ instead of $_SERVER['PHP_SELF'].
Or you can put a workaround in your cli wrapper, by setting
$_SERVER['PHP_SELF'] or other needed $_SERVER[*] variables.
purcaholic
I beg to differ. Running print_r($_SERVER) from the CLI outputs all
sorts of stuff -- including PHP_SELF.- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
You're right, i should think a while before posting such a wrong
answer. Have confused it with $_SERVER["DOCUMENT_ROOT"] which isn't
available from cli call.
@steve:
Forgott what i wrote, you're problem is not $_SERVER variable. Maybe
setting current working directory to your root directory (/var/www/
html/) could be a sollution.
At Fri, 18 May 2007 11:51:24 -0500, Steve let his monkeys type:
i'm trying to re-use scripts, typically called via a browser, in the php
cli. the cli calls are made through cron jobs. i'm hitting some unknowns as
to path info. here's the error i'm getting thus far:
"PHP Warning: require_once(../../../../../../site.cfg.php): failed to open
stream: No such file or directory in
/var/www/html/dev/admin/cli/import.repair.orders.cli.php on line 5"
Not surprising PHP can't find it seeing the file is searched 6 dir
levels up (probably your system root I'd say)
Perhaps you'd better opt for full paths instead of relative, in that case
it doesn't matter what the cwd is during execution of your script.
Opinions differ however on what's best practice, relative or absolute.
Sh. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Vijay Kumar R Zanvar |
last post by:
Hi clc,
I want to know few examples of freestanding environments.
--
"There's money in this case, Watson," he continued,
glancing out of the window, "if there is nothing else."
- A Scandal...
|
by: Bill Davidson |
last post by:
All:
I've found the 'Environment.GetEnvironmentVariable()' method; but how do I
create and/or set an environment variable?
Thanks,
Bill
|
by: |
last post by:
Hi all, I am trying to append a certain string to the
PATH environment variable programmatically. I am able to
read what is in the variable using the System.Environment
method...
|
by: Edward |
last post by:
I've just taken over maintaining a system from a colleague who has
left. I find the following line in her code:
Dim params(2) As SqlClient.SqlParameter
params(0) = New...
|
by: Matt |
last post by:
Is there a way to retrieve the Windows Environment Variables (Such as
User ID) with Javascript in IE?
|
by: Fuzzyman |
last post by:
Hello all,
I would like to set a Windows Environment variable for another
(non-child) process.
This means that the following *doesn't* work : ::
os.environ = value
In the ``win32api``...
|
by: rossum |
last post by:
I want to declare a const multi-line string inside a method, and I am
having some problems using Environment.NewLine.
I started out with:
class foo {
public void PrintStuff() {
const...
|
by: Joe HM |
last post by:
Hello -
I am putting together a little ConsoleApplication that is supposed to
check for an Environment Variable and create it if it does not exist.
I found some code that will add a new...
|
by: smitty1e |
last post by:
Just a fun exercise to unify some of the major input methods for a
script into a single dictionary.
Here is the output, given a gr.conf file in the same directory with
the contents stated below:
...
|
by: replysonika |
last post by:
Hello,
I run a Java app with subprocess from Python script. This python
script is called from another Python Wrapper.
python = subprocess.Popen(,
stdout=subprocess.PIPE,...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
| |