RE: [PHP] PHP shell scripting..
| From: | Ryan Christensen | Date: | Sun, 22 Jul 2001 19:09:53 +0000 |
| Subject: | RE: [PHP] PHP shell scripting.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59084@lists.php.net to get a copy of this message | ||
Thanks.. that helps out a lot. Next question.. is there a way I can
prompt for input? For example.. have a prompt "Name: ".. that waits for
the user to enter their name.. and then assignes whatever they enter to
a variable. Think you can help? :)
Thanks...
---------------------
Ryan Christensen
> -----Original Message-----
> From: Kees Hoekzema [mailto:kees@tweakers.net]
> Sent: Sunday, July 22, 2001 11:41 AM
> To: Ryan Christensen
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] PHP shell scripting..
>
>
> Hello Ryan,
>
> Let me give you an example :)
> Lets use your script,
> ------------------------
> #!/usr/local/bin/php -q
>
> <?
> print "I am: $name\n";
> ?>
> ------------------------
>
> i called it echo-name.php and chmod 755 it.
> Next, im going to call it:
>
> --------------------------
> Athena:~$ name=kees
> Athena:~$ ./echo-naam
> I am: kees
> --------------------------
>
> So the trick is to set the variable BEFORE you call the
> script you can see all variables already used by linux with
> "set" you'll get something like this:
>
> --------------------------
> Athena:~$ set
> BASH=/bin/bash
> BASH_VERSINFO=([0]="2" [1]="03" [2]="0" [3]="1"
> [4]="release"
> [5]="i386-slackware-linux-gnu")
> BASH_VERSION='2.03.0(1)-release' COLUMNS=80
> DIRSTACK=()
>
> (...snip...)
>
> TERM=xterm
> UID=1034
> USER=kees
> _=./echo-naam
> file=/etc/profile.d/tetex.sh
> ignoreeof=10
> name=kees
> -----------------------------
>
> As you can see, our variable name is there, and it is set.
> to set a variable, simply type this at the commandline (or script)
> -------------
> variable=value
> ---------------
> where variable is your variable and value your value :)
>
> Good luck :)
> -Kees