The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Blitz templates for PHP 0.5.10 (Default branch) iBot Software Releases - RSS News 0 01-25-2008 10:00 PM
Where are SAM user templates stored? paqman HP-UX 5 07-23-2007 01:31 PM
Templates him Post Here to Contact Site Administrators and Moderators 2 10-17-2002 01:53 PM
site templates? solvman High Level Programming 1 01-01-2002 12:13 AM
c++ templates problems in g++ Marhinado John High Level Programming 3 09-28-2001 03:25 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-04-2007
Ernst Ernst is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 37
Reading from Templates

I am trying to write a script that would retrieve specific information from a template. I have been trying to no avail for the longest. This is what I wrote and it's not working.

cat filename | while read F5 F6
do
if [[ "$F5" = "a.RSSI" -a "$F6" ="p.RSSI" ]]
then
echo
$F5 $F6
fi
done



Here is the template (filename)

CN HR CR AF a.RSSI p.RSSI

CL01 00 01 01 2.07 4.20


Can someone tell me how to extract the info I am looking for. Your help is greatly appreciated.

Thanks!
  #2 (permalink)  
Old 05-04-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
Modify the read statement :


Code:
while read F1 F2 F3 F4 F5 F6 F7
do
   if [[ "$F5" = "a.RSSI" -a "$F6" ="p.RSSI" ]]
   then
      echo $F5 $F6
   fi
done < filename

Jean-Pierre.
  #3 (permalink)  
Old 05-04-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,245
You need to use single brackets if using -a.


Code:
while read F1 F2 F3 F4 F5 F6 F7
do
   if [ "$F5" = "a.RSSI" -a "$F6" = "p.RSSI" ]
   then
      echo $F5 $F6
   fi
done < filename

  #4 (permalink)  
Old 05-04-2007
Ernst Ernst is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 37
I keep getting the following error message:


./RSSI: a.RSSI=.RSSI: not found
./RSSI: p.RSSI=.RSSI: not found


I am not sure how to define a.RSSI and p.RSSI so that the program can read them. I added these two lines to the script, but it did not work. Somehow, I need to find a way to let the program read RSSI from the template and print its value.

a.RSSI=$a.RSSI
p.RSSI=$p.RSSI


Thanks for the help!
  #5 (permalink)  
Old 05-04-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Ernst,
Make sure there is a space after the "=":
"$F6" = "p.RSSI"
  #6 (permalink)  
Old 05-04-2007
Ernst Ernst is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 37
Yeah, The syntax is correct. But for some reason, it is not reading the RSSI values. How can I define RSSI so that the script can read the RSSI values from the template?

Does anyone know another way of writing a script that extracts information from a template?
  #7 (permalink)  
Old 03-26-2008
Ernst Ernst is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 37
Cut command

Thank you to all of you guys who posted an answer to my last inquiry. I have not been able to get back to this site for a while.
Anyway, I am trying to use the cut command do print a range of information from 1 to 87. The problem is when I use the following command line:
cd /dir/dir-data/logs/task
echo "info"
read info
read date
date=$date
d=`date +%y%m%d`
cd /dir/dir-data/logs/task
cgrep "$info" $date.task |cut -d ";" -f1-87 > /home/user/task/test/Data.$d
My cat Data.$d is empty. However, if I split my file into 4 files as follows, it works:
cgrep "$info" $date.task |cut -d ";" -f1-25 > /home/user/task/test/Data
1.$d
cgrep "$info" $date.task |cut -d ";" -f26-50 > /home/user/task/test/Data
2.$d
cgrep "$info" $date.task |cut -d ";" -f51-75 > /home/user/task/test/Data
3.$d
cgrep "$info" $date.task |cut -d ";" -f76-87 > /home/user/task/test/Data
4.$d

My question is if someone can tell me what I am doing wrong that keeps the command cgrep "$info" $date.task |cut -d ";" -f1-87 > /home/user/task/test/Data.$d from working properly. Maybe there are some restrictions with the cut command.

Thanks for the help.

E.
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0