read file column and paste it in command

Hi Unix gurus

I have a file containing 2 coloumns. I would like to do a script which reads the lines and executes a command like this:

command <field1> parameters <field2> some more parameters

Please let me know how you would do this without AWK, SED or any other mini language (for special restrictions I cannot use AWK).

A bit off topic further question - how can you check the return code of an executed command (system command) within AWK? Does $? work there too?

Cheers
BearCheese

sounds like home work can you post your effort on this??

Hi,
thanks for your reply - no it's not a homework. I would like to create a script for SAP application that can be used for mass transportation.

To be more precise the command would like the following:
tp import <field1> client<field2> u2368

the script should be able to read the parameter file from where field1 (transport number) and field2 (target client) may be inserted into the above pattern an execute it.

So far I have something like this:

#!/bin/ksh
command_part1="tp import"
command_part2="client"
command_part3="u2368"

while read line
do
fullcommand=${command_part1}" "(here I should get field1)" "${command_part2}" "(here I should get field2)" "${command_part3}
`$fullcommand`
if ($? -gt 0); then exit 8
fi
done < filename.txt

the reason I don't want to use AWK is curiosity plus I need to check the return code of the last command. If I used AWK, I could more simply do the field separation and can use the system command to execute commands but I'm not sure how to check the return code within AWK (hence my second off topic question in my original post)

I would like to know is there any way apart from AWK or SED to split the $line string into two fields, where the field seperator is a space " ". It can be comma or whatever is more comfortable.

Cheers
BearCheese

Change the way you read in the data from the file, read in as 2 variables rather than single line:

while read field1 field2
while read first second; do
  "$command_part1" "$first" "$command_part2" "$second" "$command_part3" ||
    exit 8
done < filename.txt

Thanks guys!