Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #11941
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Arno Welzel <usenet@arnowelzel.de> |
| Newsgroups | comp.lang.php |
| Subject | Re: Regarding split text and match from data base |
| Date | Sat, 23 Nov 2013 08:52:26 +0100 |
| Lines | 98 |
| Message-ID | <52905EBA.1080005@arnowelzel.de> (permalink) |
| References | <676203c7-7d21-4513-92d5-7a9111c2eaa6@googlegroups.com> <528F7980.4040500@arnowelzel.de> <l6numn$s3o$1@dont-email.me> <528F8B64.2000804@arnowelzel.de> <l6o9eb$v2b$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net QHqC/XBPT/wAXLe77Cp2SQ5nlaQ0PwooJMe4ZftOZHoWmYRj3U |
| Cancel-Lock | sha1:71WBohzRp2UZN8/Mx3NvSXdeiTE= |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 |
| In-Reply-To | <l6o9eb$v2b$1@dont-email.me> |
| X-Enigmail-Version | 1.6 |
| Xref | csiph.com comp.lang.php:11941 |
Show key headers only | View raw
Jerry Stuckle, 2013-11-22 19:57:
> On 11/22/2013 11:50 AM, Arno Welzel wrote:
>> Jerry Stuckle, 2013-11-22 16:54:
>>
>>> On 11/22/2013 10:34 AM, Arno Welzel wrote:
>>>> Am 22.11.2013 12:28, schrieb jalaf28@gmail.com:
>>>>
>>>>> Hello All I just start learning PHP and i am using 5.4.16 i just
>>>>> want to split the out put of the following and match from the
>>>>> database and print the System name.
>>>>>
>>>>> here is the Code
>>>>>
>>>>> <?php
>>>>>
>>>>> ob_start(); $line=shell_exec("arp -a"); echo "<pre>; echo $line; echo
>>>>> "</pre>";
>>>>>
>>>>> ?>
>>>>>
>>>>> It shows the output of the command "arp -a" and show the Ip address
>>>>> and Mac address on the LAN system. i saved the name and the Mac
>>>>> address in the database. now i want to extaxct the command output and
>>>>> match ["MAc address] with database and show the Particular system
>>>>> name and Ip Address. i try google but not sufficent.
>>>>
>>>> You can try explode() using space (' ') as delimiter, see:
>>>>
>>>> <http://php.net/manual/en/function.explode.php>
>>>>
>>>>
>>>>
>>>
>>> Arno,
>>>
>>> Have you actually looked at the output of arp -a? From your response, I
>>> don't think so.
>>
>> And where is your answer to the question?
>>
>> Anyway...
>>
>> arp -a outputs here (numbers as "x" for privacy reasons):
>>
>> somename (xxx.xxx.xxx.xxx) at xx:xx:xx:xx:xx:xx [ether] on eth0
>>
>> So - using explode() on this line with space as delimiter should return
>> an array with the following elements:
>>
>> somename
>> (xxx.xxx.xxx.xxx)
>> at
>> xx:xx:xx:xx:xx:xx
>> [ether]
>> on
>> eth0
>>
>> Then you can use the fourth element which contains the MAC address.
>>
>> If you get more than one line of output, the lines have to be split
>> first of course. Therefore I'd recommend using exec() which will return
>> the output as an array with one element for each line of output.
>>
>>
>>
>
> My reply is above - if you bothered to read (which you obviously
> didn't). Additionally, the output of arp -a is also dependent on the
> operating system and version of arp. Your way requires much more
> processing than a simple preg_match().
Yep - I didn't see your other post when I wrote my reply.
And yes, I'm also aware that the output of arp -a depends on the
operating system version. That's why I said - "You can try explode()"
and not "use explode() this will always work". Of course I haven taken
into account that the output format is not the same on all operating
systems.
> And in this case the regex is pretty simple, and parses the output he
> wants into a multi-dimensional array in one statement.
Sury - regex is pretty simple assuming the OP knows how to use regular
expressions ;-)
But even then additional parsing may be neccessary if arp groups
interfaces and outputs the interface description first and then a list
of entries for that interface like Windows 7 does.
Again - that's why I said "You can try explode()" - it was only a
suggestion, not a complete solution. But preg_metch() is neither.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Regarding split text and match from data base jalaf28@gmail.com - 2013-11-22 03:28 -0800
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-22 09:24 -0500
Re: Regarding split text and match from data base Arno Welzel <usenet@arnowelzel.de> - 2013-11-22 16:34 +0100
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-22 10:54 -0500
Re: Regarding split text and match from data base Arno Welzel <usenet@arnowelzel.de> - 2013-11-22 17:50 +0100
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-22 13:57 -0500
Re: Regarding split text and match from data base Arno Welzel <usenet@arnowelzel.de> - 2013-11-23 08:52 +0100
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-23 07:05 -0500
Re: Regarding split text and match from data base Arno Welzel <usenet@arnowelzel.de> - 2013-11-24 17:17 +0100
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-24 11:23 -0500
Re: Regarding split text and match from data base jalaf28@gmail.com - 2013-11-24 20:02 -0800
Re: Regarding split text and match from data base jalaf28@gmail.com - 2013-11-24 22:09 -0800
Re: Regarding split text and match from data base jalaf28@gmail.com - 2013-11-24 22:35 -0800
Re: Regarding split text and match from data base Arno Welzel <usenet@arnowelzel.de> - 2013-11-25 08:35 +0100
Re: Regarding split text and match from data base Arno Welzel <usenet@arnowelzel.de> - 2013-11-25 08:36 +0100
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-25 09:31 -0500
Re: Regarding split text and match from data base jalaf28@gmail.com - 2013-11-25 21:32 -0800
Re: Regarding split text and match from data base jalaf28@gmail.com - 2013-11-25 21:41 -0800
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-26 07:20 -0500
Re: Regarding split text and match from data base jalaf28@gmail.com - 2013-11-26 21:22 -0800
Re: Regarding split text and match from data base Arno Welzel <usenet@arnowelzel.de> - 2013-11-27 12:29 +0100
Re: Regarding split text and match from data base Arno Welzel <usenet@arnowelzel.de> - 2013-11-27 12:31 +0100
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-27 09:57 -0500
Re: Regarding split text and match from data base Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-28 12:27 +0000
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-28 11:01 -0500
Re: Regarding split text and match from data base Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-28 18:51 +0000
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-28 19:27 -0500
Re: Regarding split text and match from data base Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-29 02:34 +0000
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-28 22:47 -0500
Re: Regarding split text and match from data base Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-29 05:01 +0000
Re: Regarding split text and match from data base Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-29 07:40 -0500
Re: Regarding split text and match from data base Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-29 13:58 +0000
csiph-web