Re: php on the Command line
| From: | Bjorn Sodergren | Date: | Sun, 25 Jun 2000 23:01:58 +0000 |
| Subject: | Re: php on the Command line | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3047@lists.php.net to get a copy of this message | ||
> Maybe something like
>
> for ($i = 0; $i < $argc; $i++) {
> switch ($argv[$i]) {
> case "-i":
> $IP = $argv[++$i];
> break;
> case "-n":
> $Username = $argv[++$i];
> break;
> }
> }
>
Doh!, i tried the same thing with if statements, but i was using
$argv[$i++] !
heh,
> Of course, this doesn't really work if the user does something like "-u -n -i
> 127.0.0.1". Perhaps it'd be better to use a style such as --username=bob and parse
> everything from -- to the equal sign as the key and everything afterword as the value.
thats a good idea, this script that im working on right now is for the
root user anyways, its to add a domain, ip, user and password to
apache, proftpd, named, and mysql.
i'll be working on one for adding users to their own proftpd
authuserfile's and their vhost files (each domain is kept in a seperate
file and included into the conf.)
i cant wait for the zend compiler to come out, so i can keep the source
from prying eyes.
>
> > > If you want the user to be able to enter a value, try using fgets on stdin (See the
> > > fopen() docs for
> > > instructions on how to open stdin, stdout, or stderr). It should be somewhat like
> > > this:
> > >
> > > $stdout = fopen("php://
> stdout");
> > > $stdin = fopen("php://stdin");
> > >
> > > fputs($stdout, "Username: ");
> > > fgets($stdin, $Username);
> > >
> >
> > I really really need to sit down sometime and read EVERY page of that
> > manual :)
i tried that, i got an error, added the r+ and w+ flags (for stdout,
stdin),
and it did...
[Virtual-Support]-[/scripts]
root:>#./new.php
Password: [Virtual-Support]-[/scripts]
root:>#
this is the source to it..
#!/usr/bin/php -q
<?
$stdout = fopen("php://stdout","r+");
$stdin = fopen("php://stdin","w+");
fputs($stdout, "Password: ");
fgets($stdin, $passwd);
echo "\n".$passwd."\n";
?>
i also tried the -i flag, and the -a flag, none of em worked.
any ideas ?
>
> One thing I've been wishing is that there was some exposed versioning system in the manual
> code.
> It'd be really cool to be able to see what's new in recent versions in a form a
> little friendlier
> than diff php3_manual_file.html php4_manual_file.html.