UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old April 19th, 2004, 10:00 AM
ChrisJones ChrisJones is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 ChrisJones User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Print 3 variables on same line

hi,
I've just written a bourne shell script to be run on Solaris 5.8 to extract URL's containing issues number from some text file (such as URL) and get the current status and resolution of the issue online.

The result should display with the 3 words on the same line, 1 single space between each word, such as :
1881 CLOSED FIXED
(issue number, status, resolution)

So far I have been trying to use echo or printf with different combination but I most of the time get things like:
CLOSED FIXED (issue number does show up)
or
1881
CLOSED FIXED (not the same line)

If anyone could give me a clue, that would be great!
thanks!

The script is ran like this:
script.sh mail.txt (data file)

code:

#!/bin/sh


LIST_OF_URLS=`grep 'http://.*/show_bug.cgi' $1 | tr -d [=\>=][:blank:]| sort | uniq`

for URL in $LIST_OF_URLS
do

PAGE_TEXT=`lynx -dump $URL`

THIS_ID=`echo "$URL" | nawk -F 'id=' '{print $2}'`

STATUS=`echo "$PAGE_TEXT" | grep ']Status:' | tr -d [:lower:][:digit:][=[=][=]=][=:=] | nawk -F ' ' '{print $2}'`

RESOLUTION=`echo "$PAGE_TEXT" | grep ']Resolution:' | nawk -F '\[' '{print $2}' | tr -d [:lower:][:digit:][=[=][=]=][=:=] | nawk -F ' ' '{print $2}'`

echo $THIS_ID $STATUS $RESOLUTION

done


I have attached a sample data file for testing
Attached Files
File Type: txt mail.txt (7.6 KB, 125 views)

Reply With Quote
  #2  
Old April 19th, 2004, 11:32 AM
munkfish's Avatar
munkfish munkfish is offline
funky munky
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2001
Location: UK
Posts: 1,446 munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 18 h 33 m
Reputation Power: 9
This script outputs:

10797 CLOSED FIXED
1881 STARTED
787 RESOLVED LATER

for me on FreeBSD with the script and data file you provided - is that not correct?

I'm wondering if it's perhaps some difference between nawk on the different OS's you're testing on? How about if you used sed instead of awk to get the id:

Code:
THIS_ID=`eval echo "$URL" | sed -e 's/.*id=\(.*\)$/\1/'`


which should ensure you don't catch any newline chars at the end of the URL (as I say though it works ok for me with freebsd's nawk). Alternatively you could use expr(1) as well I believe, although I'm not sure about the syntax for expr(1).

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Print 3 variables on same line


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway