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

PHP system() call with variables

I'm looking to use the system (or exec) function to call a shell
script in UNIX. The following is the UNIX command line without PHP:

/home/public_html/VariableDirectory/myScript.ksh

VariableDirectory can be a number of different directories. Each of
them contain a copy of myScript.ksh.
So, we run the same script in different directories like this:

/home/public_html/FirstDirectory/myScript.ksh
and
/home/public_html/SecondDirectory/myScript.ksh

Now, regarding PHP:
I'm looking to have the web-user decide in which VariableDirectory
he/she wants to run myScript.ksh. Therefore, I'm looking to have a
system() call which looks something like the following:

system("/home/public_html/'".$_REQUEST[directory]."'/myScript.ksh");

However, this doesn't work. I've also tried to save
$_REQUEST[directory] as another variable and call it within the path.
For example,

$theDir = `echo $_REQUEST[directory]`;
system("/home/public_html/$theDir/myScript.ksh");

This doesn't work either. Does anyone know about the syntax for this
example of a system() call?

Thanks,
Cam
Jul 17 '05 #1
1 22171
<ca*****@rockefeller.edu> wrote in message
news:18**************************@posting.google.c om...
I'm looking to use the system (or exec) function to call a shell
script in UNIX. The following is the UNIX command line without PHP:

/home/public_html/VariableDirectory/myScript.ksh

VariableDirectory can be a number of different directories. Each of
them contain a copy of myScript.ksh.
So, we run the same script in different directories like this:

/home/public_html/FirstDirectory/myScript.ksh
and
/home/public_html/SecondDirectory/myScript.ksh

Now, regarding PHP:
I'm looking to have the web-user decide in which VariableDirectory
he/she wants to run myScript.ksh. Therefore, I'm looking to have a
system() call which looks something like the following:

system("/home/public_html/'".$_REQUEST[directory]."'/myScript.ksh");

However, this doesn't work. I've also tried to save
$_REQUEST[directory] as another variable and call it within the path.
For example,

$theDir = `echo $_REQUEST[directory]`;
system("/home/public_html/$theDir/myScript.ksh");

This doesn't work either. Does anyone know about the syntax for this
example of a system() call?

Thanks,
Cam


try putting a . in front and have the file set to 755 as in:

$theDir = `echo $_REQUEST[directory]`;
system("./home/public_html/$theDir/myScript.ksh");
or try

$theDir = `echo $_REQUEST[directory]`;
system("/bin/ksh /home/public_html/$theDir/myScript.ksh");
--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #2

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
12
by: R | last post by:
Hello everybody. I'm writing my own Content System in PHP5. I've written so far main classes for handling DB connections, XML, XForms and Sessions. But I've got problem with one thing - it's...
6
by: JLK | last post by:
I'm having a bit of a time with the following code. I can script this real easy in Bash but I'm trying to practice my C++: ******************************************************* #include...
8
by: Just Me | last post by:
With VB6 I wanted to be consistent in how I named variables so I developed the following doc. The last column is what I named the variable. I tried to be consistent wit the Win32 document but it...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
6
by: leoman730 | last post by:
This is one of the interview question this morning, hope someone can help out with this. Thanks. What is the different between System call and library call?
5
by: Henaro | last post by:
Hello~ I am having trouble setting environment variables in C++ on win32. The code that is not working is: char prxy; char pf_cmd1 = "set http_proxy="; ....
1
by: qilin | last post by:
I have perl program which use system() to call another c program meanwhile the c program also use system() to execute a linux command line ....but not sure why it doesn't work. yes, the perl...
3
by: binder.christian | last post by:
Hi! I have two applications: * mainapp.exe * plugin01.exe I have 2 "friend" variables in mainapp.exe: Friend gblConn as SqlConnection Friend gblPath as string
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.