Solved

replace the values in template for the variables

Posted on 2002-03-20
3
330 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

695 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