ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a script file that will access the config file when called and returns the definition...
../sbin/code 20
SEIS -- LOWCUT
../sbin/code 21
SEIS -- LOWCUT SLOPE
../sbin/code 22
SEIS -- NOTCH
what I need to figure out is how to call the code script and replace the definition
Something like this ...
tail -f $fname |sed 's/^.024/SEIS -- ALIAS SLOPE/'
3
6
0
206
SEIS -- ALIAS SLOPE 72
2
9
48
Except it needs to act on all of the different codes as they come in, and if possible use the code script to call the definition in the config file, and output all definitions and data for each code.
The codes range from 00 to 99
Thanks for the help.
-- And Gordon just got tagged and spun out at Bristol --
Last edited by DavidPhillips; 08-23-2003 at 10:10 PM.
cat template
*********** OBSERVERS LOG **********
Client:@001 Contractor:@002 Crew:@003
Date:@036 Time:@035 Swath:@033
System Parameters..
Aux Channels
Sample Rate:@015 usec Preamp Gain:@017 dB
Alias:@013 Hz @014 dB/Oct Lowcut:@011 Hz @021 dB/Oct Notch:@012 Hz
Data Channels
Sample Rate:@025 usec Preamp Gain:@027 dB
Alias:@023 Hz @024 dB/Oct Lowcut:@020 Hz @021 dB/Oct Notch:@022 Hz
Source Parameters..
Start Frequency:@040 Hz End Frequency:@041 Hz
Start Taper:@044 End Taper:@045
Sweep Length:@042 ms Stack Size:@038
File Number: @037 Record Length:@026 Time Break:@034 usec
Active Spread..
Line:@028 Traces:@029
and get this
Code:
cat ~/testdta |./obscript
*********** OBSERVERS LOG **********
Client:Exon Contractor:TGC Crew:310
Date:09/01/2003 Time:12:14:02 Swath:11
System Parameters..
Aux Channels
Sample Rate:2000 usec Preamp Gain:48 dB
Alias:206 Hz 72 dB/Oct Lowcut:0 Hz 72 dB/Oct Notch:0 Hz
Data Channels
Sample Rate:2000 usec Preamp Gain:48 dB
Alias: Hz dB/Oct Lowcut:0 Hz 72 dB/Oct Notch:0 Hz
Source Parameters..
Start Frequency:12 Hz End Frequency:96 Hz
Start Taper:.300 End Taper:.300
Sweep Length:6000 ms Stack Size:12
File Number: 21 Record Length:3000 Time Break:600 usec
Active Spread..
Line:123 501 - 651 Traces:135 - 285
Awesome
Now I have another problem...
If you look at @028 as an example
there will be data on code 028 several times between 000 and 099
I think I need to put the data in an array somehow and then pull it out
which should result in something like this
Code:
Active Spread..
Line:121 501 - 634 Traces001 - 134
Line:123 501 - 651 Traces:135 - 285
or probably could make this since the data only would be in an array,
Line Stations Traces
@028 @029
Line Stations Traces
121 501 - 634 001 - 134
123 501 - 651 135 - 285
Thanks,
This is getting cool.
Last edited by DavidPhillips; 09-02-2003 at 01:05 AM.
The simple way to do it would be just to put the line breaks in when you create the variable - eg replace:
else{$var{$name}=join(':',@data)}
With:
else{
if($var{$name}){$var{$name}.="\n"}
$var{$name}.=join(':',@data);
}
This will obviously not work properly if you have the 2 side by side. If that is what you want you might want to look into escape sequences and absolute positioning.
Will there always be the same number of 029s and 028s? and will they always come in the form:
029: ...
028: ...
029: ...
028: ...
029: ...
028: ...
It doesn't matter if there are others in between. IF this is the case then it would be possible just to like these two variables together in the "else" section.
I can write something for you if the statements I made earlier are true.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.