Connecting Tech Pros Worldwide Forums | Help | Site Map

How can I run shell script in php program?

Tim
Guest
 
Posts: n/a
#1: Jul 17 '05
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.

CountScubula
Guest
 
Posts: n/a
#2: Jul 17 '05

re: How can I run shell script in php program?


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" <tim_li1008@sinaman.com> wrote in message
news:e5ae706f.0403112314.15c60135@posting.google.c om...[color=blue]
> 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.[/color]


root-boy
Guest
 
Posts: n/a
#3: Jul 17 '05

re: How can I run shell script in php program?


tim_li1008@sinaman.com (Tim) wrote in
news:e5ae706f.0403112314.15c60135@posting.google.c om:
[color=blue]
> 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.
>[/color]

Try:

`/home/www/htdocs/ok`;

Note the '`' symbol, it's the one to the left, from your 1-key, above the
TAB.
Closed Thread