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

> -----Original Message-----
> From: Ryan Christensen [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, July 22, 2001 8:30 PM
> To: 'Kees Hoekzema'
> Subject: RE: [PHP] PHP shell scripting..
>
>
> I'm slightly confused as to how I would run this from a shell though..
> what would I enter in the command line then?
>
> ---------------------
> Ryan Christensen
> (mail) [EMAIL PROTECTED]
> (cell) 360-808-1506
>
> > -----Original Message-----
> > From: Kees Hoekzema [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, July 22, 2001 11:27 AM
> > To: Ryan Christensen; [EMAIL PROTECTED]
> > Subject: RE: [PHP] PHP shell scripting..
> >
> >
> > Hello Ryan,
> >
> > You can use environment variables for that, like:
> > echo $HOME;  /* Shows the HOME environment variable, if set. */
> >
> > You can also use getenv() en putenv()
> >
> > see also: http://nl.php.net/manual/en/language.variables.external.php
> >
> > hope it works :)
> > - Kees
> >
> > > -----Original Message-----
> > > From: Ryan Christensen [mailto:[EMAIL PROTECTED]]
> > > Sent: Sunday, July 22, 2001 8:19 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] PHP shell scripting..
> > >
> > >
> > > I have some questions about using PHP as a shell scripting
> > language...
> > > mainly how you pass arguments to a script on the command line.  Say
> > > I'm
> > > using:
> > >
> > > --------------------------
> > > #!/usr/local/bin/php -q
> > >
> > > <?
> > > print "I am: $name\n";
> > > ?>> > > --------------------------
> > >
> > > How do I define test from the command line (as an argument while
> > > executing the script)?
> > >
> > > Thanks in advance for the help!
> > >
> > > ---------------------
> > > Ryan Christensen
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail:
> > [EMAIL PROTECTED]
> > >
> > >
> >
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to