Skip to content
Advertisement

PHP telnet array reply parsing to store on mysql database

Hi guys i have a small project going on, and this project requires me to send a cmd via telnet to a device and i get a reply and it troughs out the ansewer on a array.. i need to parse this data só i can store in on a mysql table..

this is the data output reply from the telnet cmd..

JavaScript

basically i need to separate F/S 0/0 P = 4 ONT ID = 1,2,3,4 depending ond cmd reply this can vary up to 64 devices , MAC CONTROL= device mac. xx:xx:xx:xx:xx RUN =active Config= online, MATCH DESCRIPTION = success match

on the mysql table we have the following rows

JavaScript

i am kind of lost i have tried foreach to filter it .. but its not storing the data correctly…

edit-1

ok so i can explode the array and filter the details but i am stuck on the loop now.. its just filtering the lad ONT id device data.. i triead a foreach but its not working.. attached code below and picture its only filtering the last ONT ID and outputing the result.pic-test

JavaScript

Advertisement

Answer

Hi guys late reply but eventually managed to get the code working update on the mysql table attached working code, there were some escape security caracteres on the telnet log which were breaking the output in the middle. Obviously i must thank all the inputs from everyone (@sammitch and @jared) who participated on the replies and comments for helping me also, pointing me out on the correct steps…

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement