i have a parameter which has path of a file. Now i need to have another parameter with the content of that file. I tried the belwo script , can any one please help.
I dont want to use cat command to read. Can we do it with out using cat command.
while read line
do
DML_FILE_NAME_ORIG1=`echo $line|awk 'BEGIN { FS = "|" } ; {print $1}'`
echo "DML_FILE_NAME_ORIG1=$DML_FILE_NAME_ORIG1"
DML_FILE_NAME_NEW_MODIFIED=${AI_DML}/testharness_modified.dml
cp $DML_FILE_NAME_ORIG1 ${AI_DML}/testharness_modified.dml
sed -i '/record/r ${AI_BIN}/modift_test_harness.txt' ${AI_DML}/testharness_modified.dml
echo "Contents of DML_FILE_NAME_NEW_MODIFIED"
echo `cat $DML_FILE_NAME_NEW_MODIFIED`
done<$AI_BIN/input.txt
> cat AI_BIN/input.txt
$AI_DML/a.dml
> cat $AI_DML/a.dml
include '~$STI_TOOLS_DML/data_quality.dml';
metadata type =
/* DML Generated for SQL: SELECT * FROM cdm_5.FT_ARNGE_CRED_RISK_MTGT_FACT
* On: Thu Mar 29 06:40:06 2012
*/
record
decimal("\x01") mth_rpt_perd_dim_id /*INTEGER NOT NULL*/;
decimal("\x01") core_arnge_dim_id /*INTEGER NOT NULL*/;
end
> cat ${AI_BIN}/modift_test_harness.txt
string("\x01") key1 = NULL("");
string("\x01") key2 = NULL("");
I need to dump into variable only because in further steps i need to pass variable to ETL-graph and then it will execute using this.
Environmental issues are not there since i tried to run the script using hard coded value and it ran perfectly. Using variable only the problem comes.
cp command is not working ...... is there any other way around?
---------- Post updated at 12:13 AM ---------- Previous update was at 12:09 AM ----------
Hi Robin,
I just need the content of the file where the file path is in parameter to another parameter where it will be also having another file path with different name.
Please describe in more detail and provide examples.
cp has proven to be working a zillion times. What is its behaviour in your case that displeases you? Run it with the -x option set and show us the execution log.
DML_FILE_NAME_ORIG1=$INF_COMRCLDATAMART_DML/ft_arnge_cred_risk_mtgt_fact.dml
cp: cannot stat `$INF_COMRCLDATAMART_DML/ft_arnge_cred_risk_mtgt_fact.dml': No such file or directory
So, are you saying that you have $a set as DML_FILE_NAME_ORIG1=$INF_COMRCLDATAMART_DML/ft_arnge_cred_risk_mtgt_fact.dml then?
This will not work. You are asking the shell to work with a file that isn't one. Which is the file you actually want to work with? I presume it's the one referred to by DML_FILE_NAME_ORIG1 , i.e. $INF_COMRCLDATAMART_DML/ft_arnge_cred_risk_mtgt_fact.dml
This far down the chain of variables, the $ will just be a character. You need to get that interpreted before you call the cp command.
I would suggest that your logic is over complicated. Break it down to find a simpler way to refer to the file you need. If not, you will end up with a mess of:-
I want to use cp $a $b
$a refers to DML.....
$DML.... refers to $INF.... and a file.
It's just too messy.
Are the records in $AI_BIN/input.txt also variable names or variable assignments that you want to use? Can you share the format of that file so we can see what are trying to process.
Try to slim the code down to the minimal structure and just have a one record input file to your loop, then after pasting it into the thread along with the content of $AI_BIN/input.txt , can you run the script with ksh -x yourscript to illustrate where it is going. It might be obvious to you then, but if not I'm sure we can discuss it further.