LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-28-2008, 01:20 PM   #1
Mustafa^Qasim
Member
 
Registered: Dec 2005
Location: Lahore, PK
Distribution: Fedora 14
Posts: 105

Rep: Reputation: 16
Question How to fetch data from a webpage and a proprietary IOS


Hello! I need to know how can I accomplish these tasks and which tool will be best for it.

a) Get specific values from a webpage and store them in variable. Storing is not issue but how to catch a specific value from the output on a webpage

b) How to get logged in another device IOS .. you can assume it a Cisco router and then execute a command and catch some specific values from the output.
 
Old 03-29-2008, 08:10 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
this read an awful lot like, which you should not be asking us to do for you, but for webpages try curl or wget to obtain the data and go from there. for IOS, expect is possibly going to be a useful tool.
 
Old 03-29-2008, 08:47 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by acid_kewpie View Post
this read an awful lot like
homework?

Indeed, it looks like cut and paste from an assignment sheet...

Another interesting tool is Twill.
 
Old 03-30-2008, 07:44 AM   #4
Mustafa^Qasim
Member
 
Registered: Dec 2005
Location: Lahore, PK
Distribution: Fedora 14
Posts: 105

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by pixellany View Post
homework?

Indeed, it looks like cut and paste from an assignment sheet...

Another interesting tool is Twill.
No it's not an home work but a try to automate a personal task that I've to do everyday at office.

a) Giving IP of Cable Mode to a webpage[cabe modem status] and retrieving some values and note them manually in spreadsheet file. I want the script to automatically pass the IP to page one by one and then pick the required values and put in variable for later making report.

b) Login to CMTS's IOS and passing a single commandto show online Cable modems on each slot and pick the required values.... it looks difficult .....


so, is it clear now...wat do i want....
 
Old 03-30-2008, 12:39 PM   #5
angrybanana
Member
 
Registered: Oct 2003
Distribution: Archlinux
Posts: 147

Rep: Reputation: 21
Quote:
Originally Posted by Mustafa^Qasim View Post
a) Giving IP of Cable Mode to a webpage[cabe modem status] and retrieving some values and note them manually in spreadsheet file. I want the script to automatically pass the IP to page one by one and then pick the required values and put in variable for later making report.
This varies a lot and depends on how the website is designed. Is it a web form? does the website have an API? Parsing the result poses the same challenges.

Can you provide the html code for the webpage, and the html code for the result, and which values you want from them?
 
Old 03-30-2008, 08:35 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you know (or don't mind learning) Perl, there's a very useful module called http://search.cpan.org/~petdance/WWW...W/Mechanize.pm, specifically designed to automate handling web-pages.
 
Old 03-31-2008, 07:40 AM   #7
Mustafa^Qasim
Member
 
Registered: Dec 2005
Location: Lahore, PK
Distribution: Fedora 14
Posts: 105

Original Poster
Rep: Reputation: 16
Well, I've got somehow th idea to fetching values from a webpage....

The requesting page's concerning code is

Quote:
Please type in the CM MAC address or CM IP Address to check the status and press ENTER
<font size=+2 color=white>
<form>
<input name=t>
</form>
and the ouput code is simple the retrieved data in <pre> tag...

Quote:
<hr><PRE>****************** Cable Modem Status through CM IP Address *********************


IP Address 10.192.44.151
Package "128KbRes1.1_d.cfg"
Status Registered
CPE 00:10:B5:53:397
00:19:47:5A:36:60
Public IP
Vendor Scientific-Atlanta, Inc.
Model WebSTAR DPC2100
Firmware "(unknown)"
System Uptime 2:57:29.00
Downstream Frequency 788750000 MHz
Upstream Centre Frequency 35 MHz
Receive Power Level -2 dBmV
Transmit Power Level 42 dBmV
Signal to Noise Ratio 29 dB
</PRE><hr>

the values in bold are what i want to pick up automatically.

well, i think it is not a big deal after learning some scripting i can do it .. but the problem is the other task...

How to login to a machine's OS and pass command n pick values from the output hrougha script....? cna it be doin with Python/PHP etc or BASH scripting can do it... i don't have any idea...
 
Old 03-31-2008, 07:48 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
as i said above, check out expect.
 
Old 03-31-2008, 01:57 PM   #9
angrybanana
Member
 
Registered: Oct 2003
Distribution: Archlinux
Posts: 147

Rep: Reputation: 21
for the website side of things, perhaps something like this

Code:
#!/bin/bash

ip='192.168.0.1'
reply=$(curl "http://www.mysite.com/blah.html?t=$ip")
#reply=$(cat html)

{ read r; read t; read s; } < <( awk '/<PRE>/,/<\/PRE>/{if ($NF ~/dB(mV)?$/) {print $(NF-1)}}' <<< "$reply" )
echo "$r"
echo "$t"
echo "$s"

Last edited by angrybanana; 03-31-2008 at 01:59 PM.
 
Old 04-02-2008, 08:50 AM   #10
Mustafa^Qasim
Member
 
Registered: Dec 2005
Location: Lahore, PK
Distribution: Fedora 14
Posts: 105

Original Poster
Rep: Reputation: 16
Ya thanks it looks expect can handle that thing.... i'll check it... thank u folks....
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
read data from webpage munna_dude Programming 3 10-06-2007 05:03 AM
Cisco IOS graciejj_82 Linux - Networking 2 08-01-2006 07:42 AM
LXer: Declare your independence from proprietary software (Or how to break the habit of proprietary software) LXer Syndicated Linux News 0 07-05-2006 01:54 PM
c++ ios::app and ios::ate gearoid_murphy Programming 6 04-08-2006 07:01 AM
Ios pk21 Linux - Security 3 08-08-2003 11:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration