admin stuff

Eterm com cores aleatorias

Ainda uso o Eterm.
Nao tem suporte a UTF-8, é velho, e tdo mais… mas ainda uso, junto com o e17.
costumo usa-lo com este scriptzinho, feito a muiiiito tempo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
foreach $arg (@ARGV){
        $cmd_options="$cmd_options $arg";
}
 
$offset = 60;
$base = 80;
$limit = 400;
 
$red = int($base + rand($limit - $offset));
$green = int($base + rand($limit - $offset));
$blue = int($base + rand($limit - $offset));
 
$options = "--cmod-red $red --cmod-green $green --cmod-blue $blue";
 
exec ("Eterm $options $cmd_options");
#exec ("Eterm $options $cmd_options -T \"`fortune  -n50 -s`\"");

admin stuff
Desktop
programming

Comments (0)

Permalink

cgo.py

Lembram-se do cgo.sh?
Agora existe o cgo.py.
Faz a mesma coisa… só que em python:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# Copyright (C) 2008, Felippe Bueno <bueno>
# GNUv2 licence
# Enjoy
import sys,os
 
if len(sys.argv) &lt; 2:
    print "Use:     "+ sys.argv[0] +' server1 server2 server3... serverN'
    print "or:      "+ sys.argv[0] +' server* to use ~/.ssh/known_hosts'
    print "or:      "+ sys.argv[0] +' server 1 20 to use \'server\' as prefix, and increment from 1 to 20 (server1 server2 server3 ... server20)'
    sys.exit(1)   
 
def use_knownhosts(prefix):
    import string
    servers=""
    known_file=file(os.getenv('HOME')+'/.ssh/known_hosts','r')
    for line in known_file.readlines():
        hostname=string.split(line.split()[0], sep=',')[0]
        if prefix in hostname:
            servers=servers+' '+hostname
    args=servers.split()
    args.sort()
    cargs=""
    for s in args:
        cargs=cargs+' '+s
    return cargs
 
def use_prefixsequence(prefix,start,end):
    servers=""
    i=start
    while i &lt;= end:
        servers=servers+' '+prefix+str(i)
        i=int(i)+1
    return servers
 
if '*' in sys.argv[1]:
    import string
    os.system("cssh "+use_knownhosts(string.split(sys.argv[1],sep='*')[0]))
    sys.exit(0)
 
if len(sys.argv) == 2:
    servers=""
    i=1
    while i &lt; len(sys.argv):
        servers=servers+' '+sys.argv[i]
        i=i+1
    os.system("cssh "+servers)
    sys.exit(0)
 
try:
    int(sys.argv[2])
    int(sys.argv[3])
    os.system("cssh "+use_prefixsequence(sys.argv[1],int(sys.argv[2]),int(sys.argv[3])))
except ValueError:
    servers=""
    i=1
    while i &lt; len(sys.argv):
        servers=servers+' '+sys.argv[i]
        i=i+1
    os.system("cssh "+servers)
    sys.exit(0)</bueno>

admin stuff
Desktop
programming
Python

Comments (0)

Permalink

date -d

depois de muito tempo querendo fazer isso e de ter conseguido algumas vezes mas sempre esquecer
eu achei denovo, mas desta vez vou postar aqui pra nao esquecer:

jah usaram o date -d , certo ?

date -d "1 hour ago"
date -d "1 day ago"

etc…

agora, e pra fazer 1 hora ou 1 dia adiante ?
after ? next ?

simples:

date -d "1 day"
date -d "1 hour"

admin stuff

Comments (0)

Permalink

todo/get_field.py

sim, funcionou….
no .muttrc:

1
2
macro index < Esc>w "|formail  -x Subject: -x From: | get_field.py | todo -a -p 4\r"
macro pager  < Esc>w "|formail  -x Subject: -x From: | get_field.py | todo -a -p 4\r"

tem q ter o procmail (pra usar o formail):

1
sudo aptitude install procmail

get_field.py:

1
2
3
4
5
6
7
8
#!/usr/bin/env python
 
import sys
from email.Header import decode_header
 
for f in sys.stdin.readlines():
        field=decode_header(f)
        print field[0][0]

admin stuff
Desktop

Comments (0)

Permalink

CB

[www@cb.vu]~> ls -l
-rw-r—–   1 colin   www   1045 Feb 15 01:31 about.txt
-rw-r—–   1 colin   www   4033 Feb 11 02:06 cb.txt
-rw-r—–   1 colin   www  98166 Jul 23  2004 exploring.gif
-rw-r—–   1 colin   www   1150 Jan 31 15:17 favicon.ico
-rw-r—–   1 colin   www   1933 Feb 10 16:53 index.html
-rw-r—–   1 colin   www  25695 Feb  5 00:52 shell.js
-rw-r—–   1 colin   www    766 Feb 10 01:13 sitemap.xml
-rw-r—–   1 colin   www  64720 Feb 10 01:13 termlib.js
-rw-r—–   1 colin   www   5838 Feb 10 02:14 termlib_parser.js
-rw-r—–   1 colin   www 272458 Feb 10 02:14 unixtoolbox.book.pdf
-rw-r—–   1 colin   www 271664 Feb 10 02:14 unixtoolbox.book2.pdf
-rw-r—–   1 colin   www 345472 Feb 10 02:14 unixtoolbox.pdf
-rw-r—–   1 colin   www 124113 Feb 25 04:20 unixtoolbox.txt
-rw-r—–   1 colin   www 156225 Feb 11 01:47 unixtoolbox.xhtml
-rw-r—–   1 colin   www   1992 Feb 11 02:50 vars.js.php
[www@cb.vu]~> more about.txt
Welcome to my website cb.vu!
This site provides a virtual shell and is meant to be a command line joke where
you have to use some UNIX commands to get around. There are some
functionalities which are not totally fake, like the commands ping, whereami,
weather. Besides ping and weather, there is no communication whatsoever between
the browser and the server. Everything is happening within your navigator. You
can however create files on the web root directory and even view them with the
browser by entering the file name in the address bar. For example try:
echo ”Hello there, my name is Colin.” > hello.txt
 – MORE –  (Type: space to continue, ’q' to quit)

O site do cara do post anterior é bemmm legal tb.

admin stuff
Desktop
Server

Comments (0)

Permalink

UnixToolBox

Falando sobre receitas de bolo.

Achei em um share do google reader, uma url que pode ser util, o Unix ToolBox, com comandos de varios unixes (linux/bsd/solaris) e até de windows, alem de nocoes basicas em linguagens de programacao, utilidades de redes, entre outros. Vale ter no bookmarks.

admin stuff
Server

Comments (0)

Permalink

UNetbootin

É dificil de acompanhar estes assuntos….

Me lembro qd era necessario (pra mim, até hoje),  sempre seguir uma receita de bolo para colocar uma distro linux em um pendrive usb (sticky), pois nunca me lembrava como fazer (nao faco tantas vezes assim). Mas pra este caso existe o UNetbootin que faz tdo isso de dentro do windows.

admin stuff

Comments (0)

Permalink

Installing Debian From Ubuntu or any other GNU/Linux

É engracado como sempre encontramos em ferramentas que utilizamos todos os dias uma funcionalidade nova.

Por ex. Para instalar um debian de dentro de qq ubuntu, ou de qq outro linux eu normalmente baixaria o debootstrap.

Mas existe uma maneira bem simples de fazer isso, tdo bem q vc precisa reiniciar o sistema.

Mas mesmo assim, um conceito interessante.

Tratasse de colocar o initrd.gz e o vmlinuz (alem do iso q ira usar na instalacao) dentro de um diretorio qualquer, depois configure uma entrada para eles no seu boot loader…

Ao invez de reproduzir tdo o artigo, vou so dar o link .

admin stuff
ubuntu

Comments (0)

Permalink

Landscape

What is Landscape?

Landscape is a system management service that allows you to manage multiple Ubuntu machines as easily as one. Canonical Support customers can manage many machines in a complex environment through a single web-based interface. Simply register the machines in Landscape to gain control of numerous systems management and resourcing tools.

What does Landscape do?

Like many businesses yours is likely deploying more Ubuntu machines running more applications and packages. This requires more administration. Additionally, environments are becoming increasingly complex with virtualized machines and appliances running as peers to standard software applications. Ubuntu on server and desktop can run the lot but you need control. That’s where Landscape fits in. There is the package and security updates management you might expect, but Canonical Landscape has also built in a host of additional monitoring, user control, process management, inventory control and support enhancement tools that we describe in detail below.

http://www.canonical.com/projects/landscape

admin stuff
Server
ubuntu

Comments (0)

Permalink

Cluster SSH

 sudo aptitude install clusterssh

Depois bem simples o scriptao, mas util:

1
vim cgo.sh

cgo.sh:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
 
if `echo $* | grep "*" > /dev/null`; then
        servers=""
        server=`echo $1 | cut -d* -f1`
        for x in `egrep ^$server ~/.ssh/known_hosts | cut -d, -f1`
        do
                servers="$servers $x"
        done
        cssh $servers
        exit
fi
 
if `echo $2 | egrep '^[0-9]' > /dev/null ` &&  `echo $3 | egrep '^[0-9]' > /dev/null`; then
        servers=""
        for x in `seq $2 $3`
        do
                servers="$servers "$1""$x""
        done
        cssh $servers
        exit
fi
 
cssh $*
exit

da pra colocar no /etc/bash_completion tb…

soh achar a linha

 complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
ping fping telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr cgo.sh

que ele vai comecar a completar com o tab utilizando o /etc/hosts e o ~/.ssh/known_hosts
lembresse de desabilitar o HashKnownHosts colocando no

cgo.sh

admin stuff

Comments (1)

Permalink