473,382 Members | 1,658 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,382 software developers and data experts.

shell script - to not change working directory to that of the script


Hi,

I'm running a PHP script from a shell (bash, ...) - not from a web
server.

So I use a script of the form:

#!/usr/bin/php
<?php
var_dump($argv);
?>

and then I can run the script directly, rather than:
[user]# php -f script_name

Running the script this way changes the current directory to that of
the script.

I don't want this behaviour - I want the current directory to be from
where I run the script, so I can write the PHP code to work on 'local'
files (./*) - just like it should for CLI SAPI interface.

I can't use the -C option (PHP throws an error) like:

#!/usr/bin/php -q -C

Anyone know how to do what I want ?

System: Linux Fedora Core 1, PHP Version 4.3.8

Thanks,
John.

Jul 17 '05 #1
1 2806
> I don't want this behaviour - I want the current directory to be from
where I run the script, so I can write the PHP code to work on 'local'
files (./*) - just like it should for CLI SAPI interface.


John,

Can't you simply give your script a parameter of the needed working
directory and then
use the chdir()-command to change the script's current directory?

regards,

Gert.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Bowling | last post by:
I'm creating a routine (not in a browser) to move multiple files on a daily basis to a backup directory. It can be done easily by call shell functions like 'mv file* newdir'. I can't find any...
2
by: Jorgen Grahn | last post by:
I couldn't think of a good solution, and it's hard to Google for... I write python command-line programs under Win2k, and I use the bash shell from Cygwin. I cannot use Cygwin's python package...
9
by: Jeff Wagner | last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to getting started? Thanks, Jeff
8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
2
by: Andy B. | last post by:
I've got a python utility that I want to change my shell's current directory based on criteria it finds. I've scoured google and the python cookbook and can't seem to figure out if this is even...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
2
by: kalaisuresh | last post by:
Hai , I have a shell script in my directory filename = c ----- #/bin/bash clear ----- root>c if i run this script in my directory it is working
2
by: jonathan184 | last post by:
Hi I am trying to create a shell script that will look for a contracthead file first and if the contract head file does not exist on day1 exit script. Now on day2 if contracthead exists or...
2
Colloid Snake
by: Colloid Snake | last post by:
Hello everyone- I am working on a shell script to parse out a Node.def file that contains the hostname, version, IP address, and date updated. There is a separate .def file for each node (of which...
1
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...
0
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...
0
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
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?
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...

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.