Register
It is currently Thu Oct 02, 2014 6:27 am

Variable inside <>


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon Feb 21, 2011 9:36 am   

Joined: Tue Jan 18, 2011 6:18 am
Posts: 14
Hi,

I have a simple problem.
I have a script that is trying to place a variable inside a XML tag but it's being ignored.
I am querying a web page that outputs xml and am trying to get the value between certain tags.

URL to query:
"https://www.somesite.tld/monitor.asp?cmd=getNoOfSuccessfulTransactionsVendor&dur=300&vendor=somecustomer"

Result:
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <vspaccess>
<errorcode>0000</errorcode>
<nooftransctions>55</nooftransctions>
<timestamp>21/02/2011 13:23:10</timestamp>
</vspaccess>

So in the example above I want the value of 55 only.

Here's my script:
___________
#!/bin/bash

LYNX=`which lynx`
SED=`which sed`
URL="https://www.somesite.tld/monitor.asp"
CMD=$1
DUR=$2
VENDOR=$3
TAG=$4

#
$LYNX -source "$URL?cmd=$CMD&dur=$DUR&vendor=$VENDOR" | $SED 's%.*<$TAG>\(.*\)</$TAG>.*%\1%p'
_______________

So I run:
./XMLData getNoOfSuccessfulTransactionsVendor 300 somecustomer nooftransctions

Unfortunately the $TAG variable is not being read correctly and I'm assuming it's because it's between ''

Any help please?


Top
 Profile  
 PostPosted: Mon Feb 21, 2011 9:55 am   

Joined: Tue Jan 18, 2011 6:18 am
Posts: 14
Nevermind I realised it's because of the single quote character.
I substituted it for double quotes and it fixed my problem.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP