Writing HTML with variables from an array or other means
Hello!
I wish to create a script that will automate the creation of HTML files...
for example, if my HTML starts out containing:
I want to put that into something that I can read and write later on. My idea was to put that into an array, then call it like so:
Then later:
This doesn't work, as there are quotes and other characters I assume will be mis-interpreted by bash.
I want to be able to write the HTML lines without having to escape quotes and other characters and as my HTML changes, I want to make it simple for me to just drop in the modified HTML code into the array.
Please let me know if there is an easy way to go about this, or if what I am trying to accomplish does not make sense.
Thank you in advance!
Last edited by Scrutinizer; 05-09-2013 at 03:50 PM..
Reason: code tags
Thank you for the reply, but that's the same thing as doing echo for each line and escaping the quotes.. I am trying to find a way where you don't have to do all that. Also, noted about the code tags.
Still escaping quotes... goal is to not have to modify the HTML content to do that.
---------- Post updated at 02:22 PM ---------- Previous update was at 02:21 PM ----------
... or is there a way I can do that in the 'for z in' ... statement so that quotes are automatically escaped? I don't want to have to manually escape quotes every time I edit the HTML - I will have a large number of lines so this is all about the convenience of being able to drop in new HTML whenever I want without filtering/escaping manually.
---------- Post updated at 02:47 PM ---------- Previous update was at 02:22 PM ----------
The below works for quotes- but the problem is that if you introduce an HTML 'tick mark' character ' then it breaks.
Hello, I wrote code that generates an image that writes its contents to a Targa file. Due to modifications that I wish to do, I decided to copy the value of each pixel as they are calculated to a dynamically allocated array before write it to a file. The problem is now that I all I see is a big... (2 Replies)
I need shell script for the following specfic need, I'll get following output after running my program.
I wanted every 50th row in the coloumn and take into array.
For example input
==============
03
03
03
03
05
05
05
05
07
07
07
07
I wanted to extract 3,5,7 and store it in... (12 Replies)
I'm writing a perl script that writes an html file.
use Tie::File;
my ($dir) = @ARGV;
open (HTML,">","$dir/file.html") || die $!;
#-----Building HTML file---------------------------
print HTML "<!DOCTYPE html>
<html>
<head>
<title>Output</title>
<link... (3 Replies)
Hi,
I'm having an issue with echo again. I keep getting errors and no file content with these commands in a script.
---------------------------------------------------
#!/bin/bash
WEBSITE=http://www.google.com
touch test1.txt
echo "replace("<body>","<body><iframe... (2 Replies)
Hi,
Im used to compiling when i stumble upon some interesting topics in the net and convert it into pdf files unto my HD for future reference's. I using the chrome print to pdf procedure since firefox html to pdf don't work correctly.
I just wonder in someone do same thing and did it in a easy... (3 Replies)
Hi,
Basically what I am trying to do is the following.
I have created a shell script to grab timetabling information from a website using curl then I crop out only the data I need which is a table based on the current date. It leaves me with a file that has the table I want plus a small amount... (2 Replies)
Hi All,
How do I write into shared memory blocks using multiple threads? For example, I have created 50 threads to write into shared memory and 50 threads to read from shared memory.
I have already created a shared memory and I want to write into shared memory as follows:
... (0 Replies)
echo "Please enter your surname\n"
echo "followed by your first name:\c"
read name1 name2
echo "Thank you"
echo "Now please enter your age"
read age
echo "Thanks again, we're nearly done. Please enter your town of birth"
read town
echo "Hi there $name2 $name1"
sleep 3
echo "erm..."
sleep... (6 Replies)
I have a loop which will go round "i" number of times and return a value each time. Is there a way to set a variable(i) such that I will end up with variable(1), variable(2), variable(3) etc. for however many times the loop went round?
eg:
for (i=1;i<=3;i++)
--do some sums--... (0 Replies)