Quantcast
Channel: THWACK: Popular Discussions - IP Address Manager
Viewing all articles
Browse latest Browse all 12396

How to Do URL Queries Using CURL

$
0
0

Howdy, folks!  I'm pretty new to SolarWinds IPAM.  And while I've been scripting for a while, I feel I'm still relatively new to `curl'.  At any rate, here's my premise:  if I can pass a URL successfully to my browser and get good data, I should be able to pass the same URL to `curl' to get text-based output.  Unfortunately, I've been hitting my head up against a wall, and I'm out of tricks at this point. 


Why am I doing this?  Ultimately, I want to get IP Assignment History.  But I'm taking baby steps, and here's what I'm sending to my browser right now.  It's an IPAM query equivalent to a basic `nslookup', viz., "http://solarwinds/Orion/IPAM/search.aspx?q=192.168.11.10"  Note that this is an internal address, and that I actually get a hostname back when I send this to my browser.

 

However, when I try to lookup the same URL from the command line, I don’t get the expected output.  Instead, I get garbage. 

 

Here's my simplified `curl' statement:

$ curl -L -u USER http://solarwinds/Orion/IPAM/search.aspx?q=192.168.11.10

Enter host password for user 'USER':

 

<garbage>

 

Full disclosure:  here’s my actual script…

#!/usr/bin/sh


# Dynamic Variables

# -----------------

IP_LOOKUP="192.168.11.10"

URL="http://solarwinds/Orion/IPAM/search.aspx?q=${IP_LOOKUP}"

BROWSER='Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)'

COOKIE='XLI5P8GU.txt'

 

# Get IP History

# -----------------

curl -L-c${COOKIE}-u USER -A "${BROWSER}" "${URL}" | \

sed 's/<[^>]*>//g'

 

…and here’s what happens when I run it:  I get nothing relevant after stripping out the HTML

# ./curl_solarwinds.sh

Enter host password for user 'USER':

<I enter this manually>


(function(){var de=$(document.documentElement); de.addClass('sw-is-locale-en'); $.each(jQuery.browser,function(k,v){if(v===true){ de.addClass('sw-is-'+k); de.addClass('sw-is-'+k+'-'+parseInt(jQuery.browser.version)); }}); })();

SW.Core.Loader._cbLoaded('jquery');

SW.Core.Date._init(0,-25200000);

 

 

<white space removed>

 

 

 

    window.location = 'Login.aspx';

 

  

Your ninja-kungfu-help is appreciated!

 

Sumair


Viewing all articles
Browse latest Browse all 12396

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>