Solved

replace the values in template for the variables

Posted on 2002-03-20
3
303 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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now