Re: php on the Command line
| From: | MichaelWaples | Date: | Mon, 26 Jun 2000 18:20:40 +0000 |
| Subject: | Re: php on the Command line | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3162@lists.php.net to get a copy of this message | ||
On phpbuilder.com there's a great article on php on the command line.
The sites down so here's a function from it -
function read() {
$fp=fopen("/dev/stdin", "r");
$input=fgets($fp, 255);
fclose($fp);
return str_replace( "\n", "", $input);
}
I use it all the time
eg. $userid = read();
you can also get somene to enter a password and have it do the lookup
and keep prompting until it's right.
I just compiled php without apache.
I have command line scripts for - adding domains to httpd.conf, adding
ftp accounts for proftpd, adding a domain for tinydns, and creating
email accounts for qmail. Also scripts for removing domains too. They
all save the data to a postgresql table so I can keep track of
everything. It saves hours in adding new domains. Adding 20 or 30
domains to all those by hand is not fun.
For security since others will be using it - I have a user called admin
- in the sudoers file I put only the commands I want my scripts to run
as root.
Each script will have to run as admin -
Then in my sudoers file I have my admin scripts which my users can run
as admin using sudo.
So they aren't running the script as root or even as admin, I'll be
doing some checking on what their inputs are too, as well I have passord
protection ast the start of each script.
I'll then force them to use ssh.
I still haven't decided to put a webinterface yet but it will be easy to
convert anyway and just run the web server as admin.
Bjorn Sodergren wrote:
>
> > Don't rely on it for security as it's just not possible to prevent someone from
> > decrypting it.
> > Security should be enforced with tightly restricted account permissions that way even a
> > full copy of
> > the source won't help.
>
> of course :)
> most of the security will have to be built into the script itself, to
> prevent users from executing commands and whatnot.
>
> > > i also tried the -i flag, and the -a flag, none of em worked.
> > >
> > > any ideas ?
> >
> > Try using "w" and "r" without the plus signs, which shouldn't be
> > necessary.
>
> i tried both of those, they didnt work either, there was no output.
>
> [Virtual-Support]-[/scripts]
> root:>#./new.php
>
> [Virtual-Support]-[/scripts]
> root:>#
>
> [Virtual-Support]-[/scripts]
> root:>#php -q new.php
>
> [Virtual-Support]-[/scripts]
> root:>#
>