perl

Simple qmail-queue wrapping with perl

Tagged:  

I wanted to add the same dynamic email signature to all the email I send whether it is from my cellphone or from my computer.

My email client at home (mutt) makes it easy to take the output of a script and use it as a sig, but my cell phone can't do anything like that.

I just configured my qmail to replace a tag in mails from me with my signature. Qmail's modular design makes it easy to overload certain parts of it.

Crontab based tagging of Delicious bookmarks

Tagged:  

I was trying to think of a way to keep myself from checking google news every 15 minutes, while at the same time making myself check other websites periodically.

I came up with a solution whereby a perl script uses the delicious API on CPAN to add a tag to bookmarks that contain a crond directive.

This way I can just pull up all my boookmarks with the toread tag when I have time do do some web browsing. I can make googlenews only come up twice a day.

Automatically login to a wifi captive portal with perl and WWW::Mechanize

Tagged:  

It annoying when you have to enter your username and password into a captive portal day after day. With a super simple perl script using WWW::Mechanize and a wireless connection manager like wicd you can make it all happen automagically.

Here is the script I use to auto login to the wireless connection at starbucks.

On demand port swapping for piercing firewalls

Tagged:  

So I got a nice little acer aspire one, and I've been using the wifi around town. It is really annoying when you get behind a firewall that only lets certain ports out.

I wrote a perl cgi script that will set up iptables port forwarding rules to put a service (like ssh or a vpn) on a non-restricted port (like 443). The rule only affects the IP address from which the cgi was accessed.

of course it has to run as root to set up the iptables rules.

Automatically add and remove groups to a user

Tagged:  

So I wanted to write a shell script to add groups to users. I found out that usermod can only set all group memberships at once, there is no way to simply add one group at a time.

I wrote a perl script to do what I want. Just call it with -a 'group' to add a group to a user and -d 'group' to remove a group. You can comma seperate multiple groups or use multiple switches on the command line. Of course you have to be root.

Note that this script makes assumptions about the output of the groups command. It expects groups to output like "user : initialgroup extended1 extended2"

Maybe I will clean it up one day to not use the groups command and do more sanity checks. Right now it relies on usermod to check that users and groups exist.

Syndicate content