Replacing new line in text file with tag in a HTML fileCopy file while replacing text in itReplace text/string with new lineAdd text with echo but start with new line if file not emptyfinding and replacing textsed command not replacing a text with newline characterRemove tag and contents based on child tag and add a new content - Shellscript xmlSplitting a text file into new filesExtracting values from a text file having | pipe as a delimiter in text file using awk command and Replacing new lines with <br> tag using sed?Pull values from text file to create new fileRead from a file and return new line with loop
Averaging over columns while ignoring zero entries
Create chunks from an array
Draw this image in the TIKZ package
Short story about an infectious indestructible metal bar?
Use Mercury as quenching liquid for swords?
What does *dead* mean in *What do you mean, dead?*?
Why restrict private health insurance?
What is the best index strategy or query SELECT when performing a search/lookup BETWEEN IP address (IPv4 and IPv6) ranges?
Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?
Why would /etc/passwd be used every time someone executes `ls -l` command?
I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?
Can I negotiate a patent idea for a raise, under French law?
Are small insurances worth it?
Why do we call complex numbers “numbers” but we don’t consider 2-vectors numbers?
Will the concrete slab in a partially heated shed conduct a lot of heat to the unconditioned area?
Is "cogitate" used appropriately in "I cogitate that success relies on hard work"?
ESPP--any reason not to go all in?
Generating a list with duplicate entries
How can I have x-axis ticks that show ticks scaled in powers of ten?
What the error in writing this equation by latex?
Why does a car's steering wheel get lighter with increasing speed
Tabular environment - text vertically positions itself by bottom of tikz picture in adjacent cell
Why does this boat have a landing pad? (SpaceX's GO Searcher) Any plans for propulsive capsule landings?
Rationale to prefer local variables over instance variables?
Replacing new line in text file with
tag in a HTML file
Copy file while replacing text in itReplace text/string with new lineAdd text with echo but start with new line if file not emptyfinding and replacing textsed command not replacing a text with newline characterRemove tag and contents based on child tag and add a new content - Shellscript xmlSplitting a text file into new filesExtracting values from a text file having | pipe as a delimiter in text file using awk command and Replacing new lines with <br> tag using sed?Pull values from text file to create new fileRead from a file and return new line with loop
Actually, i am making a self made tool "MOM" for my infrastructure team in my office.
My tool has one text file "mom.txt" and a HTML file named as "mom.html" . I have a shell script that takes copy of "mom.html" and name it as momcpy.html
I send this momcpy.html file in a mail as a report of meetings to my Team DL.
I am attaching the image of my tool and different files here:
My Tool for sending "Minute of meetings" to Team mail:
Now here at the end, i have submit button , when i click on it , it sends the html report to the mail that is the file "momcpy.html"
My "mom.txt" file is given below :
Saibal,Navnath,Taral,Sagar,Ankit,Prasham,Manika,Arvind,Gaurav,Abhijeet,Rohit,Madhu,Ganesh,Zahoor|
LSCRM:Abhijeet
MCRM:Arvind
TLGAPI:Bhargav
MOM:Manikaa|
Prod :
No major activity were scheduled and no issues were reported throughout the week.
Last weekend on Sunday, we performed Full bounce. We are doing so to allow any USDOTT transaction during this window while they do code-fix (they need CRM available at all times).
Coming weekend, we have ordering client Ef deployment and CK External BLM Phase 2 activity scheduled on both APH and STL.
Non-Prod:
Over the week, we released 1710 CT11 K2view to build: 220 and Env TRN3 to 1707 Build:300.
|
PROD:
We have 2Q OS Patching on DR and Production.
There was an issue of Sync reject long response time reported for NBI Market . It was run in debug mode to investigate further.
Coming weekend, the scheduled DR switchover activity got cancelled.
Coming weekend we have Weblogic phase 2 migration activity as well as weekly config build.
Non Prod:
We have 2Q OS Patching activity on QA and TRN envs.|
PROD:
WTC cleanup activity completed successfully.
No major issues reported.
NON PROD
Configuration changes on DB end for 1710 envs done.
There was an issue due to heap size on few jvms.Clients got impacted. We tried to do Rolling bounce but issue still persist. After half an hour issue got resolved itself.
|
No updates|
break|
So, on clicking the details that user input in Attendees, Agenda, LSCRMUpdates, MCRM Updates and Tlgapi Updates and Other Updates are saved in a text file "mom.txt" given above.
Now You can see that i have used pipe | as a delimiter to extract the different sections data that is given by user as an input.
Now my momcpy.html file that i send as a mail report its code:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title>CRM Infra MOM Weekly Reports</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href='http://fonts.googleapis.com/css?family=Exo:700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="mom.css">
<script src="mom.js"></script>
</head>
<body onLoad="xx()">
<p class="exe1"><div id="content-wrap">
<p class="exe1"><h1 valign="top">CRM Infra Weekly Report</h1></p>
<br/>
<p class="exe1"><table align="center" border="6" cellpadding="10" cellspacing="10">
<tr>
<th height="15" style="font-size:20px;line-height:10px;" bgcolor="#808080"><label for="attendees">Attendees</label></th>
</tr>
<tr>
<td><textarea rows="10" cols="140">attendees</textarea></td>
</tr>
<tr>
<th height="12" bgcolor="#808080">Agenda:</th>
</tr>
<tr>
<td height="70" bgcolor="#FFFFFF">agenda.</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="lscrm">LSCRM:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">lscrm</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="mcrm">MCRM:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">mcrm</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="mcrm">TLGAPI:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">tlgapi</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="other">Other Updates:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">other</td>
</tr>
</table></p>
</div></p>
</body>
</html>
In this file i have a table with row and columns same like my Tool table structure.
Here i have different variables in different rows like lscrm, mcrm, agenda, attendees, tlgapi and i replace those variables with the values present in mom.txt file (Value given as an input by user) using pipe as a delimiter.
I do this by using shell script:
#! /bin/bash -x
file='/home/websphe/tomcat/webapps/MOM/mom.txt'
file1='/home/websphe/tomcat/webapps/MOM/web/mom.html'
common_path='/home/websphe/tomcat/webapps/MOM/web/'
if test -s $file
then
cp $file1 $common_path/momcpy.html
attendees=$( awk 'BEGIN RS = " NR == 1 print ' $file )
echo "$attendees"
agenda=$( awk 'BEGIN RS = " NR == 2 print ' $file )
echo "$agenda"
lscrm=$( awk 'BEGIN RS = " NR == 3 print ' $file )
echo "$lscrm"
mcrm=$( awk 'BEGIN RS = " NR == 4 print ' $file )
echo "$mcrm"
tlgapi=$( awk 'BEGIN RS = " NR == 5 print ' $file )
echo "$tlgapi"
other=$( awk 'BEGIN RS = " NR == 6 print ' $file )
echo "$other"
trial=$( awk 'BEGIN RS = " NR == 7 print ' $file )
perl -p -i -e "s#attendees#$attendees#g" $common_path/momcpy.html
perl -p -i -e "s#agenda#$agenda#g" $common_path/momcpy.html
perl -p -i -e "s#lscrm#$lscrm#g" $common_path/momcpy.html
perl -p -i -e "s#mcrm#$mcrm#g" $common_path/momcpy.html
perl -p -i -e "s#tlgapi#$tlgapi#g" $common_path/momcpy.html
perl -p -i -e "s#other#$other#g" $common_path/momcpy.html
perl -p -i -e "s#trial#$trial#g" $common_path/momcpy.html
echo "`/bin/sh /home/websphe/tomcat/webapps/MOM/web/./mail.sh`"
#rm $file
# rm $common_path/momcpy.html
else
echo "Sorry no email sent :("
fi
~
MY PROBLEM STATEMENT NOW:
i Want to get the details in the same way as it is in "mom.txt" file for different sections say LSCRM Updates, MCRM Updates etc(or you can say input given by user). And since i am writing those input of text files into a HTML file, so i need to replace wherever the new line is coming with a
tag in HTML using above mentioned shell script NOTE:
I only want to add <br> tag
in the text input section not in each and every part of my html file. else it is getting aligned very down.
Currently i have used this in my script:
perl -p -i -e "s#attendees#$attendees#g" $common_path/momcpy.html
perl -p -i -e "s#agenda#$agenda#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#lscrm#$lscrm#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#mcrm#$mcrm#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#tlgapi#$tlgapi#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#other#$other#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#trial#$trial#g" $common_path/momcpy.html | sed -i'' 's|$|<br>|' $common_path/momcpy.html
But it is adding <br> tags
everywhere in my HTML file and the table is getting alligned very down in browser Chrome or IE.
shell-script
add a comment |
Actually, i am making a self made tool "MOM" for my infrastructure team in my office.
My tool has one text file "mom.txt" and a HTML file named as "mom.html" . I have a shell script that takes copy of "mom.html" and name it as momcpy.html
I send this momcpy.html file in a mail as a report of meetings to my Team DL.
I am attaching the image of my tool and different files here:
My Tool for sending "Minute of meetings" to Team mail:
Now here at the end, i have submit button , when i click on it , it sends the html report to the mail that is the file "momcpy.html"
My "mom.txt" file is given below :
Saibal,Navnath,Taral,Sagar,Ankit,Prasham,Manika,Arvind,Gaurav,Abhijeet,Rohit,Madhu,Ganesh,Zahoor|
LSCRM:Abhijeet
MCRM:Arvind
TLGAPI:Bhargav
MOM:Manikaa|
Prod :
No major activity were scheduled and no issues were reported throughout the week.
Last weekend on Sunday, we performed Full bounce. We are doing so to allow any USDOTT transaction during this window while they do code-fix (they need CRM available at all times).
Coming weekend, we have ordering client Ef deployment and CK External BLM Phase 2 activity scheduled on both APH and STL.
Non-Prod:
Over the week, we released 1710 CT11 K2view to build: 220 and Env TRN3 to 1707 Build:300.
|
PROD:
We have 2Q OS Patching on DR and Production.
There was an issue of Sync reject long response time reported for NBI Market . It was run in debug mode to investigate further.
Coming weekend, the scheduled DR switchover activity got cancelled.
Coming weekend we have Weblogic phase 2 migration activity as well as weekly config build.
Non Prod:
We have 2Q OS Patching activity on QA and TRN envs.|
PROD:
WTC cleanup activity completed successfully.
No major issues reported.
NON PROD
Configuration changes on DB end for 1710 envs done.
There was an issue due to heap size on few jvms.Clients got impacted. We tried to do Rolling bounce but issue still persist. After half an hour issue got resolved itself.
|
No updates|
break|
So, on clicking the details that user input in Attendees, Agenda, LSCRMUpdates, MCRM Updates and Tlgapi Updates and Other Updates are saved in a text file "mom.txt" given above.
Now You can see that i have used pipe | as a delimiter to extract the different sections data that is given by user as an input.
Now my momcpy.html file that i send as a mail report its code:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title>CRM Infra MOM Weekly Reports</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href='http://fonts.googleapis.com/css?family=Exo:700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="mom.css">
<script src="mom.js"></script>
</head>
<body onLoad="xx()">
<p class="exe1"><div id="content-wrap">
<p class="exe1"><h1 valign="top">CRM Infra Weekly Report</h1></p>
<br/>
<p class="exe1"><table align="center" border="6" cellpadding="10" cellspacing="10">
<tr>
<th height="15" style="font-size:20px;line-height:10px;" bgcolor="#808080"><label for="attendees">Attendees</label></th>
</tr>
<tr>
<td><textarea rows="10" cols="140">attendees</textarea></td>
</tr>
<tr>
<th height="12" bgcolor="#808080">Agenda:</th>
</tr>
<tr>
<td height="70" bgcolor="#FFFFFF">agenda.</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="lscrm">LSCRM:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">lscrm</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="mcrm">MCRM:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">mcrm</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="mcrm">TLGAPI:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">tlgapi</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="other">Other Updates:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">other</td>
</tr>
</table></p>
</div></p>
</body>
</html>
In this file i have a table with row and columns same like my Tool table structure.
Here i have different variables in different rows like lscrm, mcrm, agenda, attendees, tlgapi and i replace those variables with the values present in mom.txt file (Value given as an input by user) using pipe as a delimiter.
I do this by using shell script:
#! /bin/bash -x
file='/home/websphe/tomcat/webapps/MOM/mom.txt'
file1='/home/websphe/tomcat/webapps/MOM/web/mom.html'
common_path='/home/websphe/tomcat/webapps/MOM/web/'
if test -s $file
then
cp $file1 $common_path/momcpy.html
attendees=$( awk 'BEGIN RS = " NR == 1 print ' $file )
echo "$attendees"
agenda=$( awk 'BEGIN RS = " NR == 2 print ' $file )
echo "$agenda"
lscrm=$( awk 'BEGIN RS = " NR == 3 print ' $file )
echo "$lscrm"
mcrm=$( awk 'BEGIN RS = " NR == 4 print ' $file )
echo "$mcrm"
tlgapi=$( awk 'BEGIN RS = " NR == 5 print ' $file )
echo "$tlgapi"
other=$( awk 'BEGIN RS = " NR == 6 print ' $file )
echo "$other"
trial=$( awk 'BEGIN RS = " NR == 7 print ' $file )
perl -p -i -e "s#attendees#$attendees#g" $common_path/momcpy.html
perl -p -i -e "s#agenda#$agenda#g" $common_path/momcpy.html
perl -p -i -e "s#lscrm#$lscrm#g" $common_path/momcpy.html
perl -p -i -e "s#mcrm#$mcrm#g" $common_path/momcpy.html
perl -p -i -e "s#tlgapi#$tlgapi#g" $common_path/momcpy.html
perl -p -i -e "s#other#$other#g" $common_path/momcpy.html
perl -p -i -e "s#trial#$trial#g" $common_path/momcpy.html
echo "`/bin/sh /home/websphe/tomcat/webapps/MOM/web/./mail.sh`"
#rm $file
# rm $common_path/momcpy.html
else
echo "Sorry no email sent :("
fi
~
MY PROBLEM STATEMENT NOW:
i Want to get the details in the same way as it is in "mom.txt" file for different sections say LSCRM Updates, MCRM Updates etc(or you can say input given by user). And since i am writing those input of text files into a HTML file, so i need to replace wherever the new line is coming with a
tag in HTML using above mentioned shell script NOTE:
I only want to add <br> tag
in the text input section not in each and every part of my html file. else it is getting aligned very down.
Currently i have used this in my script:
perl -p -i -e "s#attendees#$attendees#g" $common_path/momcpy.html
perl -p -i -e "s#agenda#$agenda#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#lscrm#$lscrm#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#mcrm#$mcrm#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#tlgapi#$tlgapi#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#other#$other#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#trial#$trial#g" $common_path/momcpy.html | sed -i'' 's|$|<br>|' $common_path/momcpy.html
But it is adding <br> tags
everywhere in my HTML file and the table is getting alligned very down in browser Chrome or IE.
shell-script
add a comment |
Actually, i am making a self made tool "MOM" for my infrastructure team in my office.
My tool has one text file "mom.txt" and a HTML file named as "mom.html" . I have a shell script that takes copy of "mom.html" and name it as momcpy.html
I send this momcpy.html file in a mail as a report of meetings to my Team DL.
I am attaching the image of my tool and different files here:
My Tool for sending "Minute of meetings" to Team mail:
Now here at the end, i have submit button , when i click on it , it sends the html report to the mail that is the file "momcpy.html"
My "mom.txt" file is given below :
Saibal,Navnath,Taral,Sagar,Ankit,Prasham,Manika,Arvind,Gaurav,Abhijeet,Rohit,Madhu,Ganesh,Zahoor|
LSCRM:Abhijeet
MCRM:Arvind
TLGAPI:Bhargav
MOM:Manikaa|
Prod :
No major activity were scheduled and no issues were reported throughout the week.
Last weekend on Sunday, we performed Full bounce. We are doing so to allow any USDOTT transaction during this window while they do code-fix (they need CRM available at all times).
Coming weekend, we have ordering client Ef deployment and CK External BLM Phase 2 activity scheduled on both APH and STL.
Non-Prod:
Over the week, we released 1710 CT11 K2view to build: 220 and Env TRN3 to 1707 Build:300.
|
PROD:
We have 2Q OS Patching on DR and Production.
There was an issue of Sync reject long response time reported for NBI Market . It was run in debug mode to investigate further.
Coming weekend, the scheduled DR switchover activity got cancelled.
Coming weekend we have Weblogic phase 2 migration activity as well as weekly config build.
Non Prod:
We have 2Q OS Patching activity on QA and TRN envs.|
PROD:
WTC cleanup activity completed successfully.
No major issues reported.
NON PROD
Configuration changes on DB end for 1710 envs done.
There was an issue due to heap size on few jvms.Clients got impacted. We tried to do Rolling bounce but issue still persist. After half an hour issue got resolved itself.
|
No updates|
break|
So, on clicking the details that user input in Attendees, Agenda, LSCRMUpdates, MCRM Updates and Tlgapi Updates and Other Updates are saved in a text file "mom.txt" given above.
Now You can see that i have used pipe | as a delimiter to extract the different sections data that is given by user as an input.
Now my momcpy.html file that i send as a mail report its code:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title>CRM Infra MOM Weekly Reports</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href='http://fonts.googleapis.com/css?family=Exo:700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="mom.css">
<script src="mom.js"></script>
</head>
<body onLoad="xx()">
<p class="exe1"><div id="content-wrap">
<p class="exe1"><h1 valign="top">CRM Infra Weekly Report</h1></p>
<br/>
<p class="exe1"><table align="center" border="6" cellpadding="10" cellspacing="10">
<tr>
<th height="15" style="font-size:20px;line-height:10px;" bgcolor="#808080"><label for="attendees">Attendees</label></th>
</tr>
<tr>
<td><textarea rows="10" cols="140">attendees</textarea></td>
</tr>
<tr>
<th height="12" bgcolor="#808080">Agenda:</th>
</tr>
<tr>
<td height="70" bgcolor="#FFFFFF">agenda.</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="lscrm">LSCRM:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">lscrm</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="mcrm">MCRM:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">mcrm</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="mcrm">TLGAPI:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">tlgapi</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="other">Other Updates:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">other</td>
</tr>
</table></p>
</div></p>
</body>
</html>
In this file i have a table with row and columns same like my Tool table structure.
Here i have different variables in different rows like lscrm, mcrm, agenda, attendees, tlgapi and i replace those variables with the values present in mom.txt file (Value given as an input by user) using pipe as a delimiter.
I do this by using shell script:
#! /bin/bash -x
file='/home/websphe/tomcat/webapps/MOM/mom.txt'
file1='/home/websphe/tomcat/webapps/MOM/web/mom.html'
common_path='/home/websphe/tomcat/webapps/MOM/web/'
if test -s $file
then
cp $file1 $common_path/momcpy.html
attendees=$( awk 'BEGIN RS = " NR == 1 print ' $file )
echo "$attendees"
agenda=$( awk 'BEGIN RS = " NR == 2 print ' $file )
echo "$agenda"
lscrm=$( awk 'BEGIN RS = " NR == 3 print ' $file )
echo "$lscrm"
mcrm=$( awk 'BEGIN RS = " NR == 4 print ' $file )
echo "$mcrm"
tlgapi=$( awk 'BEGIN RS = " NR == 5 print ' $file )
echo "$tlgapi"
other=$( awk 'BEGIN RS = " NR == 6 print ' $file )
echo "$other"
trial=$( awk 'BEGIN RS = " NR == 7 print ' $file )
perl -p -i -e "s#attendees#$attendees#g" $common_path/momcpy.html
perl -p -i -e "s#agenda#$agenda#g" $common_path/momcpy.html
perl -p -i -e "s#lscrm#$lscrm#g" $common_path/momcpy.html
perl -p -i -e "s#mcrm#$mcrm#g" $common_path/momcpy.html
perl -p -i -e "s#tlgapi#$tlgapi#g" $common_path/momcpy.html
perl -p -i -e "s#other#$other#g" $common_path/momcpy.html
perl -p -i -e "s#trial#$trial#g" $common_path/momcpy.html
echo "`/bin/sh /home/websphe/tomcat/webapps/MOM/web/./mail.sh`"
#rm $file
# rm $common_path/momcpy.html
else
echo "Sorry no email sent :("
fi
~
MY PROBLEM STATEMENT NOW:
i Want to get the details in the same way as it is in "mom.txt" file for different sections say LSCRM Updates, MCRM Updates etc(or you can say input given by user). And since i am writing those input of text files into a HTML file, so i need to replace wherever the new line is coming with a
tag in HTML using above mentioned shell script NOTE:
I only want to add <br> tag
in the text input section not in each and every part of my html file. else it is getting aligned very down.
Currently i have used this in my script:
perl -p -i -e "s#attendees#$attendees#g" $common_path/momcpy.html
perl -p -i -e "s#agenda#$agenda#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#lscrm#$lscrm#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#mcrm#$mcrm#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#tlgapi#$tlgapi#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#other#$other#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#trial#$trial#g" $common_path/momcpy.html | sed -i'' 's|$|<br>|' $common_path/momcpy.html
But it is adding <br> tags
everywhere in my HTML file and the table is getting alligned very down in browser Chrome or IE.
shell-script
Actually, i am making a self made tool "MOM" for my infrastructure team in my office.
My tool has one text file "mom.txt" and a HTML file named as "mom.html" . I have a shell script that takes copy of "mom.html" and name it as momcpy.html
I send this momcpy.html file in a mail as a report of meetings to my Team DL.
I am attaching the image of my tool and different files here:
My Tool for sending "Minute of meetings" to Team mail:
Now here at the end, i have submit button , when i click on it , it sends the html report to the mail that is the file "momcpy.html"
My "mom.txt" file is given below :
Saibal,Navnath,Taral,Sagar,Ankit,Prasham,Manika,Arvind,Gaurav,Abhijeet,Rohit,Madhu,Ganesh,Zahoor|
LSCRM:Abhijeet
MCRM:Arvind
TLGAPI:Bhargav
MOM:Manikaa|
Prod :
No major activity were scheduled and no issues were reported throughout the week.
Last weekend on Sunday, we performed Full bounce. We are doing so to allow any USDOTT transaction during this window while they do code-fix (they need CRM available at all times).
Coming weekend, we have ordering client Ef deployment and CK External BLM Phase 2 activity scheduled on both APH and STL.
Non-Prod:
Over the week, we released 1710 CT11 K2view to build: 220 and Env TRN3 to 1707 Build:300.
|
PROD:
We have 2Q OS Patching on DR and Production.
There was an issue of Sync reject long response time reported for NBI Market . It was run in debug mode to investigate further.
Coming weekend, the scheduled DR switchover activity got cancelled.
Coming weekend we have Weblogic phase 2 migration activity as well as weekly config build.
Non Prod:
We have 2Q OS Patching activity on QA and TRN envs.|
PROD:
WTC cleanup activity completed successfully.
No major issues reported.
NON PROD
Configuration changes on DB end for 1710 envs done.
There was an issue due to heap size on few jvms.Clients got impacted. We tried to do Rolling bounce but issue still persist. After half an hour issue got resolved itself.
|
No updates|
break|
So, on clicking the details that user input in Attendees, Agenda, LSCRMUpdates, MCRM Updates and Tlgapi Updates and Other Updates are saved in a text file "mom.txt" given above.
Now You can see that i have used pipe | as a delimiter to extract the different sections data that is given by user as an input.
Now my momcpy.html file that i send as a mail report its code:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title>CRM Infra MOM Weekly Reports</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href='http://fonts.googleapis.com/css?family=Exo:700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="mom.css">
<script src="mom.js"></script>
</head>
<body onLoad="xx()">
<p class="exe1"><div id="content-wrap">
<p class="exe1"><h1 valign="top">CRM Infra Weekly Report</h1></p>
<br/>
<p class="exe1"><table align="center" border="6" cellpadding="10" cellspacing="10">
<tr>
<th height="15" style="font-size:20px;line-height:10px;" bgcolor="#808080"><label for="attendees">Attendees</label></th>
</tr>
<tr>
<td><textarea rows="10" cols="140">attendees</textarea></td>
</tr>
<tr>
<th height="12" bgcolor="#808080">Agenda:</th>
</tr>
<tr>
<td height="70" bgcolor="#FFFFFF">agenda.</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="lscrm">LSCRM:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">lscrm</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="mcrm">MCRM:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">mcrm</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="mcrm">TLGAPI:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">tlgapi</td>
</tr>
<tr>
<th height="12" bgcolor="#808080"><label for="other">Other Updates:</label></th>
</tr>
<tr>
<td height="60" bgcolor="#FFFFFF">other</td>
</tr>
</table></p>
</div></p>
</body>
</html>
In this file i have a table with row and columns same like my Tool table structure.
Here i have different variables in different rows like lscrm, mcrm, agenda, attendees, tlgapi and i replace those variables with the values present in mom.txt file (Value given as an input by user) using pipe as a delimiter.
I do this by using shell script:
#! /bin/bash -x
file='/home/websphe/tomcat/webapps/MOM/mom.txt'
file1='/home/websphe/tomcat/webapps/MOM/web/mom.html'
common_path='/home/websphe/tomcat/webapps/MOM/web/'
if test -s $file
then
cp $file1 $common_path/momcpy.html
attendees=$( awk 'BEGIN RS = " NR == 1 print ' $file )
echo "$attendees"
agenda=$( awk 'BEGIN RS = " NR == 2 print ' $file )
echo "$agenda"
lscrm=$( awk 'BEGIN RS = " NR == 3 print ' $file )
echo "$lscrm"
mcrm=$( awk 'BEGIN RS = " NR == 4 print ' $file )
echo "$mcrm"
tlgapi=$( awk 'BEGIN RS = " NR == 5 print ' $file )
echo "$tlgapi"
other=$( awk 'BEGIN RS = " NR == 6 print ' $file )
echo "$other"
trial=$( awk 'BEGIN RS = " NR == 7 print ' $file )
perl -p -i -e "s#attendees#$attendees#g" $common_path/momcpy.html
perl -p -i -e "s#agenda#$agenda#g" $common_path/momcpy.html
perl -p -i -e "s#lscrm#$lscrm#g" $common_path/momcpy.html
perl -p -i -e "s#mcrm#$mcrm#g" $common_path/momcpy.html
perl -p -i -e "s#tlgapi#$tlgapi#g" $common_path/momcpy.html
perl -p -i -e "s#other#$other#g" $common_path/momcpy.html
perl -p -i -e "s#trial#$trial#g" $common_path/momcpy.html
echo "`/bin/sh /home/websphe/tomcat/webapps/MOM/web/./mail.sh`"
#rm $file
# rm $common_path/momcpy.html
else
echo "Sorry no email sent :("
fi
~
MY PROBLEM STATEMENT NOW:
i Want to get the details in the same way as it is in "mom.txt" file for different sections say LSCRM Updates, MCRM Updates etc(or you can say input given by user). And since i am writing those input of text files into a HTML file, so i need to replace wherever the new line is coming with a
tag in HTML using above mentioned shell script NOTE:
I only want to add <br> tag
in the text input section not in each and every part of my html file. else it is getting aligned very down.
Currently i have used this in my script:
perl -p -i -e "s#attendees#$attendees#g" $common_path/momcpy.html
perl -p -i -e "s#agenda#$agenda#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#lscrm#$lscrm#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#mcrm#$mcrm#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#tlgapi#$tlgapi#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#other#$other#g" $common_path/momcpy.html | sed -i'' 's|n|<br>|' $common_path/momcpy.html
perl -p -i -e "s#trial#$trial#g" $common_path/momcpy.html | sed -i'' 's|$|<br>|' $common_path/momcpy.html
But it is adding <br> tags
everywhere in my HTML file and the table is getting alligned very down in browser Chrome or IE.
shell-script
shell-script
edited 4 hours ago
Rui F Ribeiro
41.2k1481140
41.2k1481140
asked Sep 8 '17 at 16:23
Abhijeet AnandAbhijeet Anand
44
44
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Easy, just remove the g
flag in your commands as it causes to replace all occurences.
Thanks for quick reply , i have doubt as g flag is in perl statement and its output is an input to sed command where n is replaced by <br> tag?
– Abhijeet Anand
Sep 8 '17 at 18:53
its not working getting same issue of <br> tag every where in html file.
– Abhijeet Anand
Sep 8 '17 at 19:26
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f391189%2freplacing-new-line-in-text-file-with-br-tag-in-a-html-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Easy, just remove the g
flag in your commands as it causes to replace all occurences.
Thanks for quick reply , i have doubt as g flag is in perl statement and its output is an input to sed command where n is replaced by <br> tag?
– Abhijeet Anand
Sep 8 '17 at 18:53
its not working getting same issue of <br> tag every where in html file.
– Abhijeet Anand
Sep 8 '17 at 19:26
add a comment |
Easy, just remove the g
flag in your commands as it causes to replace all occurences.
Thanks for quick reply , i have doubt as g flag is in perl statement and its output is an input to sed command where n is replaced by <br> tag?
– Abhijeet Anand
Sep 8 '17 at 18:53
its not working getting same issue of <br> tag every where in html file.
– Abhijeet Anand
Sep 8 '17 at 19:26
add a comment |
Easy, just remove the g
flag in your commands as it causes to replace all occurences.
Easy, just remove the g
flag in your commands as it causes to replace all occurences.
answered Sep 8 '17 at 16:34
αғsнιηαғsнιη
17k102966
17k102966
Thanks for quick reply , i have doubt as g flag is in perl statement and its output is an input to sed command where n is replaced by <br> tag?
– Abhijeet Anand
Sep 8 '17 at 18:53
its not working getting same issue of <br> tag every where in html file.
– Abhijeet Anand
Sep 8 '17 at 19:26
add a comment |
Thanks for quick reply , i have doubt as g flag is in perl statement and its output is an input to sed command where n is replaced by <br> tag?
– Abhijeet Anand
Sep 8 '17 at 18:53
its not working getting same issue of <br> tag every where in html file.
– Abhijeet Anand
Sep 8 '17 at 19:26
Thanks for quick reply , i have doubt as g flag is in perl statement and its output is an input to sed command where n is replaced by <br> tag?
– Abhijeet Anand
Sep 8 '17 at 18:53
Thanks for quick reply , i have doubt as g flag is in perl statement and its output is an input to sed command where n is replaced by <br> tag?
– Abhijeet Anand
Sep 8 '17 at 18:53
its not working getting same issue of <br> tag every where in html file.
– Abhijeet Anand
Sep 8 '17 at 19:26
its not working getting same issue of <br> tag every where in html file.
– Abhijeet Anand
Sep 8 '17 at 19:26
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f391189%2freplacing-new-line-in-text-file-with-br-tag-in-a-html-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown