Constructing a string by reading the contents of 2 files
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:
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:
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
Last edited by Franklin52; 04-28-2010 at 03:11 AM..
Reason: adding code tags
I have a directory with the files,
1st: I want to Diplay each filename, underline it
2nd: Display the contents under the filename and
3rd: Redirect the above content to other file
4th: Remove the files from the directory
#!/bin/ksh
for i in $( cat $a/b/c.txt )
do
echo "... (1 Reply)
We're using a ksh script for installing one product.
I've another config file, I'd need to read this configuration file from my main script
Content of the Configuration file:... (2 Replies)
Hi,
I am doing something basic, but I am missing something. Im trying to read the contents of a file and taking those values and connecting to a database. However, it only connect to one (or reads in) value and then exists.
Here is what it looks like:
listname.txt
db1
db2
db3
Script:... (15 Replies)
Hi Guys,
I need to read a file until I find a blank line. and in the next iteration I want to continue reading from the line I find a keyword.
For ex: my file looks like
PDS_JOB_ALIAS
CRITERIA_ITEM_TYPE
PDS_JOB_CRITERIA_ITEM
CRITERIA_ITEM_TYPE
First I want to read the file... (2 Replies)
Data
I was trying to write shell script which will be return the output in the below format
First i was trying to do these using sed.
sed -n '/.ksh/p' mainksh.ksh
sed -e 's/*\(.*\)/\1/g' mainksh.ksh
$RUN_DIR, $SUB_DIR and the variables which will be defined in the profile file.
when i am... (0 Replies)
I need to replace all filesnames in a folder as well as its content from AK6 to AK11. Eg Folder has files AK6-Create.xml, AK6-system.py etc.. the files names as well as contents should be changes to AK9-Create.xml, AK9-system.py etc
All files are xml and python scripts.
---------- Post... (0 Replies)
Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me .
Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer.
I want to create a mutiple output files with each file having a... (2 Replies)
I have a file which has following contents:
localhost_IP_SIP_1233026552455.xml
localhost_IP_SIP_1233026552460.xml
localhost_IP_SIP_1233026552467.xml
localhost_IP_SIP_1233026552759.xml
localhost_IP_SIP_1233026552969.xml
localhost_IP_SIP_1233026552975.xml ... (2 Replies)
Hi guys,
I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help.
I have 2 input files (example given below)
Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
I am experimenting with one of my TSM processes, and I am trying to write something to a 4mm tape.
I tried to use the tctl command, but, I was unsuccessful.
what AiX command can I run in order to see if my output is on the tape ?
Thank You ! (0 Replies)