Executing Commands Remotely with SSH

Posted by John
on Sunday, 05 October 2008

Turns out you can actually run commands remotely via SSH, plant some scripts on your server and boom you can clear your logs, backup your db and restart your webservers all without having to remote in; major help!

For example;

ssh -i /home/me/.ssh/mybox root@mybox.com '/var/www/apps/myapp/start-myapp.sh'

Here I'm specifying an ssh key file to use to connect to the remote box via the -i parameter, then the username root (because we want the script to have all the power it needs to without specifying sudo; web address of the box (or you can use the ip address). Then surrounding the command I want to run in single-quotes.

Simple effective and saves me from remoting in one night when I'm not myself, hitting the wrong key & doing something I really shouldn't ;-)

Javascript - Killing the TAB Key

Posted by John
on Monday, 10 March 2008

One thing that might muck up your beautifully designed AJAX popups is the user repeatedly hitting the tab key, simple way of stopping this is by inserting a onkeydown event for the keypress..

Trapping TAB

Simple and effective, as soon as the user's cursor gains focus for the username textbox if they then try to hit TAB within it it won't do anything; effectively trapping the action dead.

Obviously if you've got two boxes (username + password), you'll want to put this kind of trap on the password textfield otherwise the user won't be able to tab to the next cell, but as a quick fix it works well.

Setting Focus

You can also set focus via...

$('username').focus();