Combining text files as columns

To combine two (or more) text files as individual columns in the same file, such as:






[code]foo foobar
foo1 foobar1
foo2 foobar2
foo3 foobar3[/code]

rather than using an ugly combination of sed and awk, you can use the `paste’ command:

[code lang=”bash”]paste file1 file2[/code]

Red5 Installation and Usage

Red5 is an open source streaming flash media server. It’s a java-based application that is surprisingly easy to install and well-documented as such, though the documentation fails when it comes to usage — such as streaming live video.


Download from the Red5 page: . Caveat: I’ve never really gotten this page to work. I’ve mirrored it on my slice:

Java 1.5:
Java 1.6:


[code lang=”bash”]tar xzvf red5-0.8.0-java5.tar.gz[/code]


[code lang=”bash”]./[/code]

That’s it for the install. Congratulations! Red5 is running and accessible at http://your-ip:5080 .

Go there and follow the instructions. Namely, click on where it states clearly to “Click here to install demos”. Red5 ships with a number of demos that are inappropriately named but you should probably install anyway if you want to do cool things like stream live video.

“oflaDemo” is the key mis-named application that need be installed. Select and click “install”.

Thereafter, visit the Publisher utility: http://your-ip:5080/demos/publisher.html

You may need to change the server settings to point to your server (hint: won’t work — use the public IP). Create a stream with your input source (webcam, screencast, etc) and assign a stream name, and hit publish. Hurray, now that video is being broadcast over rtmp!

You can connect to this RTMP source using a Flash viewer like Flowplayer, setting the RTMP source as rtmp://your.ip/oflaDemo, with the clip URL as the name you assigned as the name in the publisher app.


Adding IP aliases in FreeBSD

Edit /etc/rc.conf:

[code lang=”bash”]ifconfig_fxp0=”inet netmask″
ifconfig_fxp0_alias0=” netmask″
ifconfig_fxp0_alias1=” netmask″
ifconfig_fxp0_alias2=” netmask″[/code]

Restart networking:

[code lang=”bash”]/etc/rc.d/netif restart && /etc/rc.d/routing restart[/code]

PHP, eval, and HTTP response codes

The PHP eval() function is an odd beast. I’ve encountered this a few times before, wherein a site will display just fine, but Google won’t index it, and if you review the headers for the page (using curl or telnet), you’ll see that instead of the expected 200 OK response, you’ll get a “HTTP/1.0 500 Internal Server Error” — bad juju for all of your hard SEO work.

Taking a look at the site’s error_log may reveal a PHP error — often a syntax error or some such. However, the line of code to which it refers is just an eval() statement for an included file.

If the eval’d code has an error, the code running the eval statement will work just fine; however, because of the error in the eval’d code, the response code header will return a 500. This, interestingly enough, will only occur if display_errors is set to off.

The ideal solution is to fix the code that is being eval’d.

The hackish way, which I prefer because I’m lazy, is to do something terrible such as:

[code lang=”PHP”]// There’s got to be a better way to do this.
ini_set(“display_errors”, “on”);
ini_set(“display_errors”, “off”);

The response code will now be 200 and Google will be happy; however, the problem isn’t *really* solved…

Better way to scan for – and clean up – virus activity

**NOTE** The following only works with FTP daemons that log full paths in xferlog — ie, not vsftpd with its default configuration. Works like a charm on Plesk, fails terribly on non-Plesk. For non-Plesk, please scroll to the bottom of this post.

I made an earlier post about this subject, but there are too many holes in the script provided. Rather, I’ve found this simple awk recipe to do the trick quite well.

[code lang=”bash”]awk ‘$12 != prev {print $9; prev=$12}’ xferlog | egrep “\.php|\.htm|\.shtm|\.js” | sort |uniq > ftp_modified.out[/code]

Note that the output it prints is not definitive, but it certainly gives you something to start with. Now, roll a grep:

[code lang=”bash”]cat ftp_modified.out |while read line; do grep -H iframe $line >> iframe.out ; done[/code]

**You will need to review this output to find the actual string and distinguish between legitimate iframes and the baddies.** The following sed will usually take care of about 80% of them:

[code lang=”bash”]cat iframe.out | awk -F\: ‘{print $1}’ | while read line ; do sed -i ‘s/