PI is not 3.14
2010
To Be Continued
my web space
To Be Continued
Several days ago a dog named Mima lost her legs just because a man living in the next house wanted to cut them off with an ax. This is happening in the town of Drianovo, Bulgaria. You can watch the official news here. The penalty for this person (in the worst case): up to 500 €.
Mima will stay down from now on. Is this the EU justice?
Write a Bash function or an alias.
####### ### alias ####### alias _rm_except="rm -rf $(ls | grep -v ^$1$)" ########## ### function ########## _rm_except () { rm -rf $(ls | grep -v ^$1$) } # sample usage: $ cd /tmp && mkdir 1 2 3 11 22 33 $ _rm_except 1; ls 11 2 22 3 33
No need for complex, unclear, and clumsy programs like Capistrano.
Use Fabric, here is a short exmple, which automates the archive process of users’ directories:
# install the Python library easy_install fabric # create a file called "fabfile" # it will be used from the "fab" command # add the following tasks in "fabfile":
from fabric.api import * env.hosts = ["main"] env.user = "root" def archive_home(): with cd("/tmp"): run("zip -rq home_`date +%Y:%m:%d-%H:%M`.zip /home") def archive_download(): import os os.system("scp %s:/tmp/home_*.zip /home/su/archive" % env.hosts[0]) def archive_remove(): run("rm /tmp/home_*.zip")
In addition you can use decorators to specify different hosts for different tasks.
More about the “fab” command:
fab --help
Usage: fab [options] (command) [:arg1,arg2=val2,host=foo,hosts='h1;h2',...] ...
Options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-l, --list print list of possible commands and exit
-d COMMAND, --display=COMMAND
print detailed info about a given command and exit
-r, --reject-unknown-hosts
reject unknown hosts
-D, --disable-known-hosts
do not load user known_hosts file
-u USER, --user=USER username to use when connecting to remote hosts
-p PASSWORD, --password=PASSWORD
password for use with authentication and/or sudo
-H HOSTS, --hosts=HOSTS
comma-separated list of hosts to operate on
-R ROLES, --roles=ROLES
comma-separated list of roles to operate on
-i KEY_FILENAME path to SSH private key file. May be repeated.
-f FABFILE, --fabfile=FABFILE
name of fabfile to load, e.g. 'fabfile.py' or
'../other.py'
-w, --warn-only warn, instead of abort, when commands fail
-s SHELL, --shell=SHELL
specify a new shell, defaults to '/bin/bash -l -c'
-c RCFILE, --config=RCFILE
specify location of config file to use
--hide=LEVELS comma-separated list of output levels to hide
--show=LEVELS comma-separated list of output levels to showCigarettes can expose you to a great danger due to a little know behavioural feature.
Imagine the way that each cigarette has – long, boring, lonely. So it’s very natural for a cigarette to become talkative once you free it from the box. And here comes the catch – you begin to socialize with the cigarettes. Which in turn makes you addicted, but even worse – this habit can peril your cosy existence to the point this person has reached:
If it happens that only root (or no one) can use key authentication, most probably the permissions are wrong. Check the following permissions:
ls -ld ~/.ssh | awk '{print $1}' # should return drwx------ # otherwise: chmod 0700 ~/.ssh
Comment