Need help on a script

Need help on a script

Post by JD Weine » Tue, 22 Dec 1998 04:00:00



Quote:> Wondering if anyone could help -- I would like to "brand" all .htm and .html
> pages on my server by automatically adding a line of javascript that calls a
> class file , regardless of ownwership (or by changing ownwership to root then
> back to owner again )does anyone know a way of "writing" this line of code to
> html pages??? without destorying the existing page (tried the << 'filename'
> but it barfed on ownership's) my linux script knowedge is minimal :( Thanks

    If you do it as root, you shouldn't have to worry about ownership at
all.  Try something like this...

echo "your stuff goes here" >> /foo/bar/yourpage.html

As for scripting it, you want a script to do several things:
-find all pages named *.htm and *.html
-see if they're already branded
-add the brand if they aren't
It might look something like this:  (this is just pseudo-code, not anything
that will actually run)

for PAGE in (`locate .htm`)
    grep "your stuff goes here" $PAGE || echo "your stuff goes here" >> $PAGE
end

    Having said that, though, I think you might be going
about things the wrong way.  I assume you're using Apache,
and I'm pretty sure Apache has a way to dynamically add
content to every page it serves.

JD Weiner
Network Messaging
Motorola SSTG