Solved

replace the values in template for the variables

Posted on 2002-03-20
3
321 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

756 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