How to pass variable to operating system.
How to pass variable to operating system.
am 09.10.2007 20:15:53 von Henk Oegema
In the php script below I use 3 variables:
1. &day
2. $hour
3. $minute.
Filename:/opt/lampp/htdocs/uptime/uptime.php
############################################################ ###############
# #
# Copyright © http://www.4webhelp.net/ #
# Neither http://www.4webhelp.net/ nor its members accept any #
# responsibility, either expressed or implied, for any damage caused by #
# using this script or the misuse of this script. #
# #
# Adapted for Asterisk PBX by Henk Oegema #
# #
# INSTRUCTIONS #
# #
# 1) Copy this code to an editor such as Notepad and save it with a #
# .php extension. #
# 2) FTP this file to a folder on your site in ASCII mode #
# 3) Call up this file in your web browser to see your server's uptime #
# #
############################################################ ###############
$data = shell_exec('uptime');
$uptime = explode(' up ', $data);
$uptime = explode(',', $uptime[1]);
$uptime = $uptime[0].' ' .$uptime[1];
$days = explode(' ', $uptime);
$hours = explode(':', $days[3]);
$day = $days[0];
$hour = $hours[0];
$minute = $hours[1];
?>
Question: How to I pass those 3 variables from the script, to 3 variables in
Linux (Debian).
Something like:
asterisk:~# day=${CURL(http://localhost/uptime/uptime.php)} (?????)
asterisk:~# hour=...........
asterisk:~# minute=.........
Re: How to pass variable to operating system.
am 09.10.2007 20:49:49 von Shion
Henk Oegema wrote:
> Question: How to I pass those 3 variables from the script, to 3 variables in
> Linux (Debian).
>
> Something like:
> asterisk:~# day=${CURL(http://localhost/uptime/uptime.php)} (?????)
> asterisk:~# hour=...........
> asterisk:~# minute=.........
You would need to use
export day=`php /path/to/yout/file/uptime.php`
if you use it this way, you need to make the script to take arguments, so that
you can get the day, hour and minute alone. Don't forget to echo about the value.
Otherwise you can use a shell script with awk that can read out the values and
then set each variable, but then you could skip using php, as you get the
uptime from uptime command directly.
--
//Aho
Re: How to pass variable to operating system.
am 09.10.2007 23:02:14 von Henk Oegema
>J.O. Aho wrote:
Tnx Aho for answering. :)
> Henk Oegema wrote:
>
>
> You would need to use
>
> export day=`php /path/to/yout/file/uptime.php`
>
> if you use it this way, you need to make the script to take arguments, so
> that
> you can get the day, hour and minute alone. Don't forget to echo about
> the value.
Can you please be a little bit more specific. It's not quit clear to me.
Why (and how) must the script take arguments?
The values of the 3 variables are already known to the script.
I only need to pass them to the operating system.
>
> Otherwise you can use a shell script with awk that can read out the values
> and then set each variable, but then you could skip using php, as you get
> the uptime from uptime command directly.
You right, this is also a possibility.
>
>
Rgds
Henk
Re: How to pass variable to operating system.
am 10.10.2007 04:42:39 von Jerry Stuckle
Henk Oegema wrote:
>> J.O. Aho wrote:
> Tnx Aho for answering. :)
>> Henk Oegema wrote:
>>
>>
>> You would need to use
>>
>> export day=`php /path/to/yout/file/uptime.php`
>>
>> if you use it this way, you need to make the script to take arguments, so
>> that
>> you can get the day, hour and minute alone. Don't forget to echo about
>> the value.
> Can you please be a little bit more specific. It's not quit clear to me.
> Why (and how) must the script take arguments?
> The values of the 3 variables are already known to the script.
> I only need to pass them to the operating system.
>> Otherwise you can use a shell script with awk that can read out the values
>> and then set each variable, but then you could skip using php, as you get
>> the uptime from uptime command directly.
> You right, this is also a possibility.
>>
> Rgds
> Henk
>
But what's the operating system going to do with them?
The operating system doesn't take parameters. Rather, you run a program
(even if it is the shell) which does something with parameters.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: How to pass variable to operating system.
am 10.10.2007 06:33:08 von Shion
Henk Oegema wrote:
>> J.O. Aho wrote:
>> Henk Oegema wrote:
>>
>>
>> You would need to use
>>
>> export day=`php /path/to/yout/file/uptime.php`
>>
>> if you use it this way, you need to make the script to take arguments, so
>> that
>> you can get the day, hour and minute alone. Don't forget to echo about
>> the value.
> Can you please be a little bit more specific. It's not quit clear to me.
> Why (and how) must the script take arguments?
> The values of the 3 variables are already known to the script.
As you can't export three shell variables at the same time, you require to set
them one at the time. If you still want to output all three at the same time
in the php script, then you need to use awk or another string manipulating
command and in which case it's less overhead to make a shell script that does
all itself.
--
//Aho
Re: How to pass variable to operating system.
am 10.10.2007 06:43:48 von Shion
Jerry Stuckle wrote:
> Henk Oegema wrote:
>>> J.O. Aho wrote:
>> Tnx Aho for answering. :)
>>> Henk Oegema wrote:
>>>
>>>
>>> You would need to use
>>>
>>> export day=`php /path/to/yout/file/uptime.php`
>>>
>>> if you use it this way, you need to make the script to take
>>> arguments, so
>>> that
>>> you can get the day, hour and minute alone. Don't forget to echo about
>>> the value.
>> Can you please be a little bit more specific. It's not quit clear to me.
>> Why (and how) must the script take arguments? The values of the 3
>> variables are already known to the script.
>> I only need to pass them to the operating system.
>>> Otherwise you can use a shell script with awk that can read out the
>>> values
>>> and then set each variable, but then you could skip using php, as you
>>> get
>>> the uptime from uptime command directly.
>> You right, this is also a possibility.
> But what's the operating system going to do with them?
> The operating system doesn't take parameters. Rather, you run a program
> (even if it is the shell) which does something with parameters.
The values are already "stored" in the OS in question, it do have track of
it's own lifespan, but of course not stored as a variable that is accessible
by the shell.
if the OP exports the value, they will only be in the shell he currently works
in, switching to another virtual console will just make that the variables in
question are empty as they never been set.
Of course it would be possible to set the values in ~/.bashrc, but then the
values will be different for each shell.
Not sure if the OP really thought about what he wants to do...
--
//Aho
Re: How to pass variable to operating system.
am 10.10.2007 08:54:29 von Henk Oegema
>
> But what's the operating system going to do with them?
>
> The operating system doesn't take parameters. Rather, you run a program
> (even if it is the shell) which does something with parameters.
Yes jerry, you are right. That's exactly what I want. :)
Sorry for my confusion.
I want to pass the values of the three variables in the php script to my PBX
dial plan (Asterisk):
exten => 3014,1,Playback(wait-moment)
exten => 3014,n,Set(days=...) <----Here I need the value of $days from the
php script.
exten => 3014,n,Set(hours=..) <----Here I need the value of $hour from the
php script.
exten => 3014,n,Set(minutes=..)<---Here I need the value of $minutes from
the php script.
exten => 3014,n,System(echo "the server uptime is ${days} days and ${hours}
hours and ${minutes} minutes" | /usr/bin/text2wave -scale 1.5 -F
8000 -o /tmp/uptime.wav)
exten => 3014,n,Playback(/tmp/uptime)
exten => 3014,n,System(rm /tmp/uptime.wav)
exten => 3014,n,Playback(goodbye)
exten => 3014,n,Hangup()
>
I use something similar to get my account balance from the web:
exten => 3000,1,Answer
exten => 3000,n,Playback(astcc-account-balance-is)
exten =>
3000,n,Set(status=${CURL(http://localhost/credit/credit_dial now.php)})
<----HERE I GET MY ACCOUNT BALANCE.
exten => 3000,n,SayDigits(${status})
exten => 3000,n,Playback(vm-goodbye)
exten => 3000,n,Hangup()
Re: How to pass variable to operating system.
am 10.10.2007 08:59:20 von Henk Oegema
J.O. Aho wrote:
> Henk Oegema wrote:
>>> J.O. Aho wrote:
>>> Henk Oegema wrote:
>>>
>>>
>>> You would need to use
>>>
>>> export day=`php /path/to/yout/file/uptime.php`
>>>
>>> if you use it this way, you need to make the script to take arguments,
>>> so that
>>> you can get the day, hour and minute alone. Don't forget to echo about
>>> the value.
>> Can you please be a little bit more specific. It's not quit clear to me.
>> Why (and how) must the script take arguments?
>> The values of the 3 variables are already known to the script.
>
> As you can't export three shell variables at the same time, you require to
> set them one at the time. If you still want to output all three at the
> same time in the php script, then you need to use awk or another string
> manipulating command and in which case it's less overhead to make a shell
> script that does all itself.
>
>
>
Please Aho see my reply to Jerry.
With awk I can get my dial plan working. :)
But I want to learn how to do it with a php script.
Re: How to pass variable to operating system.
am 10.10.2007 10:42:36 von Henk Oegema
J.O. Aho wrote:
> As you can't export three shell variables at the same time, you require to
> set them one at the time. If you still want to output all three at the
> same time in the php script, then you need to use awk or another string
> manipulating command and in which case it's less overhead to make a shell
> script that does all itself.
Now it's clear to me how it works. :)
exten => 3014,n,Set(uptime=${CURL(http://localhost/uptime/uptime.php) })
exten => 3014,n,Set(days=${uptime:0:1})
exten => 3014,n,Set(hours=${uptime:1:2})
exten => 3014,n,Set(minutes=${uptime:3:2})
(It's not the final solution yet !)
Tnx for helping (and Jerry)
Rgds
Henk
Re: How to pass variable to operating system.
am 10.10.2007 15:28:16 von Jerry Stuckle
J.O. Aho wrote:
> Jerry Stuckle wrote:
>> Henk Oegema wrote:
>>>> J.O. Aho wrote:
>>> Tnx Aho for answering. :)
>>>> Henk Oegema wrote:
>>>>
>>>>
>>>> You would need to use
>>>>
>>>> export day=`php /path/to/yout/file/uptime.php`
>>>>
>>>> if you use it this way, you need to make the script to take
>>>> arguments, so
>>>> that
>>>> you can get the day, hour and minute alone. Don't forget to echo about
>>>> the value.
>>> Can you please be a little bit more specific. It's not quit clear to me.
>>> Why (and how) must the script take arguments? The values of the 3
>>> variables are already known to the script.
>>> I only need to pass them to the operating system.
>>>> Otherwise you can use a shell script with awk that can read out the
>>>> values
>>>> and then set each variable, but then you could skip using php, as you
>>>> get
>>>> the uptime from uptime command directly.
>>> You right, this is also a possibility.
>> But what's the operating system going to do with them?
>> The operating system doesn't take parameters. Rather, you run a program
>> (even if it is the shell) which does something with parameters.
>
> The values are already "stored" in the OS in question, it do have track of
> it's own lifespan, but of course not stored as a variable that is accessible
> by the shell.
>
> if the OP exports the value, they will only be in the shell he currently works
> in, switching to another virtual console will just make that the variables in
> question are empty as they never been set.
> Of course it would be possible to set the values in ~/.bashrc, but then the
> values will be different for each shell.
>
> Not sure if the OP really thought about what he wants to do...
>
How are they "stored" in the OS? From what he's saying, they're in his
program and he needs to tell the OS about them somehow.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: How to pass variable to operating system.
am 10.10.2007 15:32:17 von Jerry Stuckle
Henk Oegema wrote:
>> But what's the operating system going to do with them?
>>
>> The operating system doesn't take parameters. Rather, you run a program
>> (even if it is the shell) which does something with parameters.
> Yes jerry, you are right. That's exactly what I want. :)
> Sorry for my confusion.
>
> I want to pass the values of the three variables in the php script to my PBX
> dial plan (Asterisk):
>
> exten => 3014,1,Playback(wait-moment)
> exten => 3014,n,Set(days=...) <----Here I need the value of $days from the
> php script.
> exten => 3014,n,Set(hours=..) <----Here I need the value of $hour from the
> php script.
> exten => 3014,n,Set(minutes=..)<---Here I need the value of $minutes from
> the php script.
> exten => 3014,n,System(echo "the server uptime is ${days} days and ${hours}
> hours and ${minutes} minutes" | /usr/bin/text2wave -scale 1.5 -F
> 8000 -o /tmp/uptime.wav)
> exten => 3014,n,Playback(/tmp/uptime)
> exten => 3014,n,System(rm /tmp/uptime.wav)
> exten => 3014,n,Playback(goodbye)
> exten => 3014,n,Hangup()
>
>
> I use something similar to get my account balance from the web:
>
> exten => 3000,1,Answer
> exten => 3000,n,Playback(astcc-account-balance-is)
> exten =>
> 3000,n,Set(status=${CURL(http://localhost/credit/credit_dial now.php)})
> <----HERE I GET MY ACCOUNT BALANCE.
> exten => 3000,n,SayDigits(${status})
> exten => 3000,n,Playback(vm-goodbye)
> exten => 3000,n,Hangup()
>
Before I get myself in trouble for making assumptions, :-) I should ask
some questions.
The stuff on the exten => lines. Are they something you type in? Are
they coming from a script file? Or are they something internal to your
dial plan?
Sorry, I'm not at all familiar with Asterisk.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: How to pass variable to operating system.
am 10.10.2007 16:35:36 von Henk Oegema
Jerry Stuckle wrote:
> Henk Oegema wrote:
>>> But what's the operating system going to do with them?
>>>
>>> The operating system doesn't take parameters. Rather, you run a program
>>> (even if it is the shell) which does something with parameters.
>> Yes jerry, you are right. That's exactly what I want. :)
>> Sorry for my confusion.
>>
>> I want to pass the values of the three variables in the php script to my
>> PBX dial plan (Asterisk):
>>
>> exten => 3014,1,Playback(wait-moment)
>> exten => 3014,n,Set(days=...) <----Here I need the value of $days from
>> the php script.
>> exten => 3014,n,Set(hours=..) <----Here I need the value of $hour from
>> the php script.
>> exten => 3014,n,Set(minutes=..)<---Here I need the value of $minutes from
>> the php script.
>> exten => 3014,n,System(echo "the server uptime is ${days} days and
>> ${hours} hours and ${minutes} minutes" | /usr/bin/text2wave -scale 1.5 -F
>> 8000 -o /tmp/uptime.wav)
>> exten => 3014,n,Playback(/tmp/uptime)
>> exten => 3014,n,System(rm /tmp/uptime.wav)
>> exten => 3014,n,Playback(goodbye)
>> exten => 3014,n,Hangup()
>>
>>
>> I use something similar to get my account balance from the web:
>>
>> exten => 3000,1,Answer
>> exten => 3000,n,Playback(astcc-account-balance-is)
>> exten =>
>> 3000,n,Set(status=${CURL(http://localhost/credit/credit_dial now.php)})
>> <----HERE I GET MY ACCOUNT BALANCE.
>> exten => 3000,n,SayDigits(${status})
>> exten => 3000,n,Playback(vm-goodbye)
>> exten => 3000,n,Hangup()
>>
>
> Before I get myself in trouble for making assumptions, :-) I should ask
> some questions.
>
> The stuff on the exten => lines. Are they something you type in? Are
> they coming from a script file? Or are they something internal to your
> dial plan?
This is what I type in myself. I make a dialplan to my own needs.
As you can see in an ealier reply to day, I've solved the problem. :)
>
> Sorry, I'm not at all familiar with Asterisk.
>
Re: How to pass variable to operating system.
am 10.10.2007 18:42:41 von Shion
Jerry Stuckle wrote:
> J.O. Aho wrote:
>> Jerry Stuckle wrote:
>>> Henk Oegema wrote:
>>>>> J.O. Aho wrote:
>>>> Tnx Aho for answering. :)
>>>>> Henk Oegema wrote:
>>>>>
>>>>>
>>>>> You would need to use
>>>>>
>>>>> export day=`php /path/to/yout/file/uptime.php`
>>>>>
>>>>> if you use it this way, you need to make the script to take
>>>>> arguments, so
>>>>> that
>>>>> you can get the day, hour and minute alone. Don't forget to echo
>>>>> about
>>>>> the value.
>>>> Can you please be a little bit more specific. It's not quit clear to
>>>> me.
>>>> Why (and how) must the script take arguments? The values of the 3
>>>> variables are already known to the script.
>>>> I only need to pass them to the operating system.
>>>>> Otherwise you can use a shell script with awk that can read out the
>>>>> values
>>>>> and then set each variable, but then you could skip using php, as you
>>>>> get
>>>>> the uptime from uptime command directly.
>>>> You right, this is also a possibility.
>>> But what's the operating system going to do with them?
>>> The operating system doesn't take parameters. Rather, you run a program
>>> (even if it is the shell) which does something with parameters.
>>
>> The values are already "stored" in the OS in question, it do have
>> track of
>> it's own lifespan, but of course not stored as a variable that is
>> accessible
>> by the shell.
> How are they "stored" in the OS? From what he's saying, they're in his
> program and he needs to tell the OS about them somehow.
>
The os is aware of the system clock and knows how many ticks it been running,
in that way the values are stored.
--
//Aho
Re: How to pass variable to operating system.
am 10.10.2007 18:44:57 von Shion
Henk Oegema wrote:
> J.O. Aho wrote:
>
>> As you can't export three shell variables at the same time, you require to
>> set them one at the time. If you still want to output all three at the
>> same time in the php script, then you need to use awk or another string
>> manipulating command and in which case it's less overhead to make a shell
>> script that does all itself.
>
> Now it's clear to me how it works. :)
>
> exten => 3014,n,Set(uptime=${CURL(http://localhost/uptime/uptime.php) })
Why use CURL???
As you are asking something from the localhost, which means the php script is
directly accessible without any use of a web server.
--
//Aho
Re: How to pass variable to operating system.
am 10.10.2007 21:09:25 von Jerry Stuckle
J.O. Aho wrote:
> Jerry Stuckle wrote:
>> J.O. Aho wrote:
>>> Jerry Stuckle wrote:
>>>> Henk Oegema wrote:
>>>>>> J.O. Aho wrote:
>>>>> Tnx Aho for answering. :)
>>>>>> Henk Oegema wrote:
>>>>>>
>>>>>>
>>>>>> You would need to use
>>>>>>
>>>>>> export day=`php /path/to/yout/file/uptime.php`
>>>>>>
>>>>>> if you use it this way, you need to make the script to take
>>>>>> arguments, so
>>>>>> that
>>>>>> you can get the day, hour and minute alone. Don't forget to echo
>>>>>> about
>>>>>> the value.
>>>>> Can you please be a little bit more specific. It's not quit clear to
>>>>> me.
>>>>> Why (and how) must the script take arguments? The values of the 3
>>>>> variables are already known to the script.
>>>>> I only need to pass them to the operating system.
>>>>>> Otherwise you can use a shell script with awk that can read out the
>>>>>> values
>>>>>> and then set each variable, but then you could skip using php, as you
>>>>>> get
>>>>>> the uptime from uptime command directly.
>>>>> You right, this is also a possibility.
>>>> But what's the operating system going to do with them?
>>>> The operating system doesn't take parameters. Rather, you run a program
>>>> (even if it is the shell) which does something with parameters.
>>> The values are already "stored" in the OS in question, it do have
>>> track of
>>> it's own lifespan, but of course not stored as a variable that is
>>> accessible
>>> by the shell.
>
>> How are they "stored" in the OS? From what he's saying, they're in his
>> program and he needs to tell the OS about them somehow.
>>
> The os is aware of the system clock and knows how many ticks it been running,
> in that way the values are stored.
>
Yes, but that's not necessarily the value in his program, is it?
Something entirely different.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: How to pass variable to operating system.
am 10.10.2007 21:16:07 von Shion
Jerry Stuckle wrote:
> J.O. Aho wrote:
>> Jerry Stuckle wrote:
>>> J.O. Aho wrote:
>>>> Jerry Stuckle wrote:
>>>>> Henk Oegema wrote:
>>>>>>> J.O. Aho wrote:
>>>>>> Tnx Aho for answering. :)
>>>>>>> Henk Oegema wrote:
>>>>>>>
>>>>>>>
>>>>>>> You would need to use
>>>>>>>
>>>>>>> export day=`php /path/to/yout/file/uptime.php`
>>>>>>>
>>>>>>> if you use it this way, you need to make the script to take
>>>>>>> arguments, so
>>>>>>> that
>>>>>>> you can get the day, hour and minute alone. Don't forget to echo
>>>>>>> about
>>>>>>> the value.
>>>>>> Can you please be a little bit more specific. It's not quit clear to
>>>>>> me.
>>>>>> Why (and how) must the script take arguments? The values of the 3
>>>>>> variables are already known to the script.
>>>>>> I only need to pass them to the operating system.
>>>>>>> Otherwise you can use a shell script with awk that can read out the
>>>>>>> values
>>>>>>> and then set each variable, but then you could skip using php, as
>>>>>>> you
>>>>>>> get
>>>>>>> the uptime from uptime command directly.
>>>>>> You right, this is also a possibility.
>>>>> But what's the operating system going to do with them?
>>>>> The operating system doesn't take parameters. Rather, you run a
>>>>> program
>>>>> (even if it is the shell) which does something with parameters.
>>>> The values are already "stored" in the OS in question, it do have
>>>> track of
>>>> it's own lifespan, but of course not stored as a variable that is
>>>> accessible
>>>> by the shell.
>>
>>> How are they "stored" in the OS? From what he's saying, they're in his
>>> program and he needs to tell the OS about them somehow.
>>>
>> The os is aware of the system clock and knows how many ticks it been
>> running,
>> in that way the values are stored.
>>
>
> Yes, but that's not necessarily the value in his program, is it?
No, it's in a way true, but the values in the script is based on it.
--
//Aho
Re: How to pass variable to operating system.
am 10.10.2007 22:42:54 von Jerry Stuckle
J.O. Aho wrote:
> Jerry Stuckle wrote:
>> J.O. Aho wrote:
>>> Jerry Stuckle wrote:
>>>> J.O. Aho wrote:
>>>>> Jerry Stuckle wrote:
>>>>>> Henk Oegema wrote:
>>>>>>>> J.O. Aho wrote:
>>>>>>> Tnx Aho for answering. :)
>>>>>>>> Henk Oegema wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> You would need to use
>>>>>>>>
>>>>>>>> export day=`php /path/to/yout/file/uptime.php`
>>>>>>>>
>>>>>>>> if you use it this way, you need to make the script to take
>>>>>>>> arguments, so
>>>>>>>> that
>>>>>>>> you can get the day, hour and minute alone. Don't forget to echo
>>>>>>>> about
>>>>>>>> the value.
>>>>>>> Can you please be a little bit more specific. It's not quit clear to
>>>>>>> me.
>>>>>>> Why (and how) must the script take arguments? The values of the 3
>>>>>>> variables are already known to the script.
>>>>>>> I only need to pass them to the operating system.
>>>>>>>> Otherwise you can use a shell script with awk that can read out the
>>>>>>>> values
>>>>>>>> and then set each variable, but then you could skip using php, as
>>>>>>>> you
>>>>>>>> get
>>>>>>>> the uptime from uptime command directly.
>>>>>>> You right, this is also a possibility.
>>>>>> But what's the operating system going to do with them?
>>>>>> The operating system doesn't take parameters. Rather, you run a
>>>>>> program
>>>>>> (even if it is the shell) which does something with parameters.
>>>>> The values are already "stored" in the OS in question, it do have
>>>>> track of
>>>>> it's own lifespan, but of course not stored as a variable that is
>>>>> accessible
>>>>> by the shell.
>>>> How are they "stored" in the OS? From what he's saying, they're in his
>>>> program and he needs to tell the OS about them somehow.
>>>>
>>> The os is aware of the system clock and knows how many ticks it been
>>> running,
>>> in that way the values are stored.
>>>
>> Yes, but that's not necessarily the value in his program, is it?
>
> No, it's in a way true, but the values in the script is based on it.
>
>
The OS doesn't know or care what the values are based on. He just needs
to put *some value* to the OS. It might come from the OS originally, an
entry that he keyed in (like he was before) or even a random number
generator.
To the OS it's all the same - something coming from a program.
And in this case it isn't going to the OS at all - but to an application
program.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: How to pass variable to operating system.
am 10.10.2007 23:34:17 von Henk Oegema
J.O. Aho wrote:
> Henk Oegema wrote:
>> J.O. Aho wrote:
>>
>>> As you can't export three shell variables at the same time, you require
>>> to set them one at the time. If you still want to output all three at
>>> the same time in the php script, then you need to use awk or another
>>> string manipulating command and in which case it's less overhead to make
>>> a shell script that does all itself.
>>
>> Now it's clear to me how it works. :)
>>
>> exten => 3014,n,Set(uptime=${CURL(http://localhost/uptime/uptime.php) })
>
> Why use CURL???
> As you are asking something from the localhost, which means the php script
> is directly accessible without any use of a web server.
Yes, the php script is directly accessible.
But I don't have enough knowledge of how to do that.
Is there another (better) way to assign the value to the variable uptime
from the php script?
>
Re: How to pass variable to operating system.
am 11.10.2007 06:45:35 von Shion
Henk Oegema wrote:
> J.O. Aho wrote:
>
>> Henk Oegema wrote:
>>> J.O. Aho wrote:
>>>
>>>> As you can't export three shell variables at the same time, you require
>>>> to set them one at the time. If you still want to output all three at
>>>> the same time in the php script, then you need to use awk or another
>>>> string manipulating command and in which case it's less overhead to make
>>>> a shell script that does all itself.
>>> Now it's clear to me how it works. :)
>>>
>>> exten => 3014,n,Set(uptime=${CURL(http://localhost/uptime/uptime.php) })
>> Why use CURL???
>> As you are asking something from the localhost, which means the php script
>> is directly accessible without any use of a web server.
> Yes, the php script is directly accessible.
> But I don't have enough knowledge of how to do that.
>
> Is there another (better) way to assign the value to the variable uptime
> from the php script?
>
php somescript.php = CURL(http://localhost/uptime/uptime.php)
You can do the following
--- yourscript ---
#!/usr/bin/php
echo "My script\n";
?>
--- eof ---
chmod 755 yourscript
$ ./yourscript
My script
$
And now you don't use the php to execute the script, it's all built in.
See to that the path is correct where php binary is located-
--
//Aho
Re: How to pass variable to operating system.
am 11.10.2007 08:30:18 von Henk Oegema
>> J.O. Aho wrote:
>>
> php somescript.php = CURL(http://localhost/uptime/uptime.php)
>
> You can do the following
>
> --- yourscript ---
> #!/usr/bin/php
>
> echo "My script\n";
> ?>
> --- eof ---
>
> chmod 755 yourscript
>
> $ ./yourscript
> My script
> $
>
> And now you don't use the php to execute the script, it's all built in.
> See to that the path is correct where php binary is located-
>
Thanks Aho :)
Rgds
Henk