Hi all - I am trying to write a script to generate a string that gets sent to an IP phone using wget. This is to upload a phone book of up to 100 entries so the string needs to be constructed in one 'hit'. I am a relative newbie to shell scripts but willing to try anything! I have 2 files:
File 1 - this is simply a list of decimal values that refer to parameters the remote device needs to refer to. There are 100 records in this file. The format is:
17253
17927
18291
18485
18676
...
File 2 - this is a CSV list of users and extension numbers. There could be anything from 1 to 100 records in this file. The format is:
Bob Smith,0501234567
Steve Gray,0507654321
Craig Hancox,0506515272
...
What I need to do is this define a string which will ultimately get sent to the phone using wget. This is construced in the following way:
1) Read the first record in File 2 (Name/Number)
2) If the record exists (i.e., not EOF), read the first record of file 1
3) Construct a string which is basically File 1: Data plus 'some text' plus File 2: Field 1 plus 'some text' plus File 2: Field 2 plus 'some text'
(note that File 2:Field 1 may contain spaces and it would really be useful of I could replace these with %20).
4) Repeat the above sequence and concatenate the results into the primary string
5) Exit the string construction phase once EOF has been reached of File 2
I can do the wget side fine - this is working... its just the string construction thing I am having real issues with. Problems I have had have been:
- Getting the script to exit after EOF of File 2
- Using awk to do the string manipulation on what it reads out of File 2
Any help or pointers would be much appreciated and i would be eternally grateful!
Best regards,
Sean