Solved

replace the values in template for the variables

Posted on 2002-03-20
3
313 Views
Last Modified: 2012-06-21
I am tring to write a shell script to generate daily html report. I have a report template file with variable names, prefixed with $ sign, like $ID, $SERVER $JOB etc. I want to create a report file with the values passed on to it. I tried cat and sed command. They do not replace the values of the variable. They just print as it is. I wuold like to keep the template file seperate from the script file which gets the values for the variables. Thank you in advance. -- Raj
0
Comment
Question by:rdr2004
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
ecw earned 200 total points
ID: 6883585
sed -e "s/\$ID/$ID/g" -e "s/\$SERVER/$SERVER/g" -e "s/\$JOB/$JOB/g" template.html > dailyreport.html

Of course, if $ID, $SERVER, or $JOB contain a '/', you'll have to use a different seperator.
0
 

Author Comment

by:rdr2004
ID: 6897137
ecw,
Thank you for the code. This works and if it is very few variables and I am creating report with variable which changes every time and each line of the report. It got very much complicated to keep them seperately. Hence I put the code and the template in one file. It works. Thanks.
- Raj
0
 

Author Comment

by:rdr2004
ID: 6897138
ecw,
Thank you for the code. This works and if it is very few variables and I am creating report with variable which changes every time and each line of the report. It got very much complicated to keep them seperately. Hence I put the code and the template in one file. It works. Thanks.
- Raj
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question