File Oddity

February 13th, 2009 No comments

Today at work I was attempting to parse a file and discovered something odd happening. When I simply viewed the file with cat, I could see this:

<html><head><title>Status</title></head>
<table>
<tr><td>Failed</td><td>Backup Group</td></tr>
<tr><td>Success</td><td>Another Backup Group</td></tr>
</table>
</body>
</html>

Nothing odd there, the file is normal but when I tried this command:

$ grep -i failed status.html
$

Huh? No output, suggesting that there is no lines with the words failed on them. The same occurs with awk and sed, indeed I could not find any tool to be able to grep out the status. So the next step was to check what was odd about the file:

$ file status.html
status.html: HTML document text

Still, nothing unusual. So now I am in full head scratching mode, I open up the file with vim to see if I can discover anything strange about the file but nothing. At this point I happened to switch to more rather than cat and the result was the start of how I solved it.

$ more status.html
��<

$

Ah, so now I can see why grep and the others cannot view anything in the file. So this time I switch to vim again and check what file encoding we have:

:set fileencoding
fileencoding=ucs-2le

For those that are unaware, this is UCS-2 (little endian), also know as UTF-16. So the issue was simply that we had UTF-16 characters, now for the trick to get around it:

$ iconv -f UTF-16 -t UTF-8 status.html | grep -i failed
<tr><td>Failed</td><td>Backup Group</td></tr>
$

Tada. Once more a solution!

Tags: ,

Fun With Bmotion

February 4th, 2009 No comments

I help out now and then with little bits of code for BMotion, the main coder is JamesOff. It is a wonderful set of scripts for AI on eggdrops. Sometimes bmotion can just spark. Check this conversation I had, both NoTopic and MonicaOff are running bmotion.

 (@  NoTopic) Uh oh, it's mark.
 (+      znx) listen nt .. im tired of your shit
 (         *) znx kicks the crap out of nt
 (         *) NoTopic passes it on to james
 (+      znx) um
 (+      znx) :[
 (@MonicaOff) cheer up mak
 (@MonicaOff) *hugs*
 (+      znx) aww
 (+      znx) i love you mon
 (         *) znx hugs
 (@MonicaOff) Hehe, want to go out on a date someplace? :)
 (+      znx) sure!
 (+      znx) where would you like to go mon?
 (@MonicaOff) Amsterdam.
 (+      znx) ooo
 (         *) znx books the flights
 (+ JamesOff) sounds nice :P
 (@  NoTopic) oh categorically abyss what do you think, talking ass?
 (+      znx) your just annoyed im not taking you nt
 (         *) znx shows nt the flight tickets
 (@  NoTopic) ooooh, impressive!
 (+      znx) :P !!
 (         *) NoTopic steals the flight tickets and runs off
 (@  NoTopic) ALL MINE NOW^@~#%~£~$$~*£$$$
 (+      znx) W T F
 (         *) NoTopic sells the flight tickets on ebay
 (+      znx) NOOOOOOOOOOooooooooooooooooooo
 (         *) znx sulks at nt
 (@  NoTopic) what

Of course sometimes bmotion is just plain evil!

Tags: , ,

No MOTD

February 3rd, 2009 No comments

I was asked today about how to stop SSH logins from printing the MOTD. This is a common issue when you are running scripts and cron e-mails you the output of the MOTD all the time. Just a little bit annoying! Instead of throwing all the data away you can instead suppress the login MOTD by simply:

touch ~/.hushlogin

In remote user’s directory. Simple!

There is also the SSH banner which doesn’t get silenced by this method, the trick to get around this is by using:

ssh -q user@server command

This isn’t ideal as it suppresses possible warnings and diagnostic information as well but it is a good workaround. Thanks to FluKex for that!

To remove the MOTD/banner all together from SSH you can edit your sshd_config and alter the line for the MOTD to no, like so:

#Banner none
PrintMotd no

Just to say a little more about hushlogin, the file and its naming choice is controlled by the /etc/login.defs file. So if you are a system administrator you could modify the naming of this file or indeed its placement. Secondly as an administrator you may wish to ensure that users don’t have this ability. The trick here is to alter the login.defs file and make the HUSHLOGIN_FILE a full pathname. Then the contents of this file will be those users that have their MOTD suppressed.

Tags: ,

AVG Update and Link Scanner Issues

February 1st, 2009 3 comments

I regularly suggest AVG as a free anti-virus solution. I have actively used it for well over 8 years now and have never found myself struck by a virus it couldn’t clean or stop.

Recently two annoyances have crept into AVG. The first is easily solvable, a corrupt update.

If you get a message saying “Invalid update control CTF file”. This means that AVG has found that its update file is corrupt. The quickest way to sort this is to delete the update files:

  • Open the “AVG User Interface”
  • Tools > Advanced settings (via the menus)
  • Then “Update” and “Manage”
  • Press “Delete temporary update files”
  • Run the update again.

Easy enough to fix.

The second annoyance is the Link Scanner. I can understand what it is attempting to do but in my preference I do not wish AVG to add additional traffic to my already clogged internet connection! The trick to sorting this is to remove the link scanner at installation. This might mean uninstalling AVG to reinstall but to get rid of Link Scanner its worth it. Simply select a “Custom installation” and then when it gets to “Component Selection” uncheck LinkScanner .. done!

Tags: ,

GNU Screen

January 31st, 2009 No comments

I am a constant user of screen and it always suprises me how many people use it and barely know how truly powerful it is. Here is a short list of some very neat tricks.

Starting a new session screen
Reattach to a session screen -r
Leave a session ^A d
Open another window ^A c
Change to a window ^A number
Change to next window ^A space
Change window via the window list ^A “
Add a split region ^A S
Jump between split regions ^A tab
Close region ^A X
Close all the other regions ^A Q
Enter “copy mode” (useful for scrollback!) ^A [
Watch for silence ^A _
Watch for activity ^A M
Protect screen with password ^A x

As always looking through info and man pages can provide a raft of information about tools and sometimes uncover tricks that you might of otherwise not known about!

Tags: