monzter
08-11-2004, 05:04 PM
Hello
I need to use PHP to pass parameter values
to shell
but I don't know how to do it!!
pls help!
thanks a lot
brendandonhu
08-11-2004, 06:06 PM
Look at these functions
http://php.net/exec
http://php.net/system
JimPanse
08-12-2004, 07:52 AM
if you do a
./php testvar.php -f=plah -g=pleh ,xyz=fnuk
to start your php from shell
then try "testvar.php" with the following code
#!/usr/bin/php
<?
var_dump($argv);
?>
i guess its what youre looking for
monzter
08-12-2004, 10:18 AM
Umm I try to make usershow.sh to recieve from viewuser.php
in php file I can use exec() to run usershow.sh
but I want to pass parameter such as $username
to shell script but I don't know how to write shell to recieve and how php pass value to shell by use exec() or system()
Thanks for every one :D
I hope this gives you an idea, if i understood you correctly try this:
PHP part:
<?php
system('/path/to/test.sh variable1');
?>
Shell (bash) part:
#!/bin/bash
echo $1
Chmod the .sh with something like 755 and then run your php script
JimPanse
08-12-2004, 10:52 AM
if you want to pass params during the runtime, you need to use any stream for.
i.e.
you can read a textfile for new lines
also you could stress mysql (selecting a table)
or you implement a socketlistener (AF_UNIX) to your script
else threre is no chance to passing vars during the scriptruntime. Not that i know.
monzter
08-12-2004, 02:56 PM
It still not work for use php to pass value to shell
I'm ok to write shell to recieve parameter form console
but pass with PHP is still not work
example
I write
on PHP
<?
shell_exec(" ./mkdir.sh newdir ");
?>
on shell
#!/bin/bash
mkdir $1
and chmod 755 with shell
I can run shell by command line ./mkdir.sh new_dir
It's OK
What should I do in this way or I have another problem with server sevice because my RH9 server is not compleately runing well
Thanks a lot for every one