Reading from Templates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading from Templates
# 1  
Old 05-04-2007
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  
Old 05-04-2007
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  
Old 05-04-2007
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  
Old 05-04-2007
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  
Old 05-04-2007
Ernst,
Make sure there is a space after the "=":
"$F6" = "p.RSSI"
# 6  
Old 05-04-2007
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  
Old 03-26-2008
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

LibreOffice Templates Custom Distro

Hello, I have a custom Linux distro in which I'm trying to get templates for LibreOffice to ship by default. Is there a location they need to be placed or a file that needs to be edited? I've already tried using the template manager and add templates that way. I then copied /usr/templates/ and... (0 Replies)
Discussion started by: TheOuterLinux
0 Replies

2. Programming

C++ templates

I have the following template codes but some normal functions too and want to group them together. I usually put the implementation of templates in an .ipp file. What would be a good scheme for the normal functions. Put their implementations in a .cpp file, or leave them in the .ipp file? ... (3 Replies)
Discussion started by: kristinu
3 Replies

3. Programming

Templates and header file

I have some C++ code and want to have the class declarations in a .h file and the implementation in the .cpp file. It seems however that for templates everything need to be put in the header (.h) file and will have problems if I try to separate the code to a .cpp file. Is this correct? Is... (1 Reply)
Discussion started by: kristinu
1 Replies

4. Solaris

A compilation problem when using templates

Hello life savers, I'm having trouble compiling a specific program. The program was originally written for gcc and was compiled successfully under it. When trying to compile under Solaris 11, I get this error: "Hashtable.h", line 170: Error: Could not find a match for hash needed in... (2 Replies)
Discussion started by: yp515
2 Replies

5. HP-UX

Where are SAM user templates stored?

Hey, new here, so be nice! I'm trying to write a little script to automate the user creation process on one of our boxes. But I would like to be able to use the templates that we have set up in SAM. Is the information in these templates stored in a file somewhere, that I can reference in my... (5 Replies)
Discussion started by: paqman
5 Replies

6. Post Here to Contact Site Administrators and Moderators

Templates

Hello, Anybody in here has any idea where I can get a template like this one for vBulletin. I have actually got my board but it just doesn't look good in the template that I have! Thanks anyway! him (2 Replies)
Discussion started by: him
2 Replies

7. Programming

site templates?

Are there any web site templates on CGI that allow like this forum software user registration and profiles. I dont need forum software i just need to register and keep profiles of my users on my site. Any suggestions? :confused: Thank you all. (1 Reply)
Discussion started by: solvman
1 Replies

8. Programming

c++ templates problems in g++

what we have: class TClass { public: TClass(); }; template<class T> class FClass<T>: public T { public: FClass(); }; TClass::TClass() { // some code } template<class T> FClass<T>::FClass : T() { // some code } int main (int argc,char* argv) { (3 Replies)
Discussion started by: Marhinado John
3 Replies
Login or Register to Ask a Question