473,406 Members | 2,371 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,406 software developers and data experts.

How can I run shell script in php program?

Tim
I have tried to write a php program to execute the shell script,but
dont know why it is not successful lei?
file: test.php
<?
system("/home/www/htdocs/ok");
?>

file: ok (permission 755)
#!/bin/bash
echo abc >> abc.txt

Why it is not successful lei(still cant see any file named as abc.txt
after run test.php)? I have tried other commands like shell_exec(),
also not work.
Jul 17 '05 #1
2 3736
the directory you are in needs to allow the user apache or nobody (depends
on your setup) to allow the creation of files.

Simpler to do this
create a dir within the dir you are in, call it _write or some thing to that
effect.

from the command line
mkdir _write
chmod 777 _write

then adust you script as so.

file: ok (permission 755)
----------------------------------
#!/bin/bash
echo abc >> ./_write/abc.txt

this way any script can create a file in the _write dir.

*or* you have to create the file abc.txt with nothing in it and make it
writable
--
Mike Bradley
http://www.gzentools.com -- free online php tools
"Tim" <ti********@sinaman.com> wrote in message
news:e5**************************@posting.google.c om...
I have tried to write a php program to execute the shell script,but
dont know why it is not successful lei?
file: test.php
<?
system("/home/www/htdocs/ok");
?>

file: ok (permission 755)
#!/bin/bash
echo abc >> abc.txt

Why it is not successful lei(still cant see any file named as abc.txt
after run test.php)? I have tried other commands like shell_exec(),
also not work.

Jul 17 '05 #2
ti********@sinaman.com (Tim) wrote in
news:e5**************************@posting.google.c om:
Why it is not successful lei(still cant see any file named as abc.txt
after run test.php)? I have tried other commands like shell_exec(),
also not work.


Try:

`/home/www/htdocs/ok`;

Note the '`' symbol, it's the one to the left, from your 1-key, above the
TAB.
Jul 17 '05 #3

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

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
2
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info...
3
by: FPGA05 | last post by:
Hello All, I am developing a small application in which I would need a C++ application to read the output from a shell script. A shell script keeps looking for user inputs and once the user...
0
by: Aashif | last post by:
I want to call Unix Shell script which is available in other Server (Unix server) from windows application using C#. Currently the shell script runs the C program but the GUI is not good, So I want...
3
by: George Sakkis | last post by:
I'm trying to figure out why Popen captures the stderr of a specific command when it runs through the shell but not without it. IOW: cmd = if 1: # this captures both stdout and stderr as...
5
by: Hul Tytus | last post by:
comp.lang.c c programs & shell conditionals How is a unix shell script made to respond to the value returned by a program compiled from c code? The shell script below is my current effort,...
5
by: inetquestion | last post by:
I am looking for a web interface for shell commands or shell scripts. Does anyone know of any exexisting php scripts which would solve this requirement? PHP form accepts input from a user, then...
3
by: Gros Bedo | last post by:
Hello :-) I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely....
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
4
by: devi thapa | last post by:
Hi, I am executing a python script in a shell script. The python script actually returns a value. So, can I get the return value in a shell script? If yes, then help me out. Regards, Devi
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: 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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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...
0
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...

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.