February 13, 2005

175 words 1 min read

Quick Perl Script

So I wanted a way to quickly add links to my homepage(/website). Its 3 easy steps

1 — “links.html” — This file either needs to be chmod 777 or chown www-data (or what ever you apache user is).

2 — Bookmark Java. I created a new bookmark in firefox with the following as location: (as put it in my toolbar for ease of use).

javascript:win=open('http://www.mypage.com/bookmark.cgi?'+document.URL, '_new','width=600,height=100');history.go(-0);

3 — “bookmark.cgi” — 4 massive lines!

#!/usr/bin/perl<br /> open(URLOUT, ">> links.html");<br /> print URLOUT "<li><a href=\"$ENV{'QUERY_STRING'}\">$ENV{'QUERY_STRING'}</a></li>\n";<br /> close(URLOUT);<br /> print "Content-Type: text/html\n\n" . "<html>BOOKMARKED:<br>\n " . $ENV{'QUERY_STRING'};<br />

4 (optional) — As you can see from above, it puts the data in

  • tags for ease of use by me. I have my index.shtml using SSI’s to pull links.html



    **Note/Warning!** First the note, you can modify the print statement to do what ever you want (no need to stick to my example). WARNING!!! There is no security! No security at all. So anyone can add links if they knew the page name. So please, security through obscurity!