rigadicomando.org

Whatever you can cat

Random Quote

When people see things as beautiful,
ugliness is created.
When people see things as good,
evil is created.

• Lao Tzu

Secondary links

  • About
  • Contacts
  • Disclaimer

fabio's blog

Unlimited Loop

Submitted by fabio on Fri, 2006-02-10 14:22.
  • bash

Generate an infinite loop in the shell

while true ; do date ; sleep 5 ; done

"Leggi Argomenti" template per script

Submitted by fabio on Tue, 2006-01-31 13:55.
  • bash
  • scripts

Template per script che legge argomenti da riga di comando:

#!/bin/bash

# FUNCTIONS

function help () {
cat <<EOF
Command:         `basename $0`
Syntax:          `basename $0` [ -h ]
Description:     Descrizione script
Options:         -h help (questo help)
                 -a Opzione "A"
                 -b Opzione "B"
EOF
}

# VARIABILI

# OPZIONI

while getopts ha:b: var
do
  case $var in
      h) help; exit
          ;;
      a) echo "Opzione "-a" con argomento $OPTARG";
          ;;
      b) echo "Opzione "-b" con argomento $OPTARG";
  esac
done
shift ` expr $OPTIND - 1 `

  • Read more

fuser + proc

Submitted by fabio on Tue, 2006-01-10 15:54.

Path completo dell'eseguibile che sta occupando una determinata
porta con un determinato protocollo

cat /proc/`fuser -n $2 $1 | gawk \'{}{printf\"%s\\n\",$2}{}\'`/cmdline && echo -e \"\\n\"

Whoix

Questo sulla mia Debian non gira ... mi sono permesso di modificarlo un po':

cat /proc/`fuser -n tcp 80|gawk {'print $2'}`/cmdline && echo

Fabio

passless users

Submitted by fabio on Tue, 2006-01-10 15:52.
  • bash

Volete vedere quali utenti nel vostro sistema NON hanno una password?

cat /etc/passwd |cut -f1,2 -d:| grep -v :x |cut -f1 -d:

Whoix

indice html per immagini

Submitted by fabio on Tue, 2006-01-10 15:50.
  • bash

Questa riga di comando genera una pagina html con link a immagini senza troppi patemi d'animo e senza troppi drag&drop :)
In pratica genera un file html definito nella variabile FILE che contiene l'elenco
delle immagini jpg presenti nella directory corrente, aggiungendo come titolo la directory
in cui ci sono le immagini e la data della generazione del documento.

blinking@X-Treme:~/foto_marte > ls -Altr
total 1030
-rw-r--r-- 1 blinking users 210036 Dec 21 1999 Image001.jpg
-rw-r--r-- 1 blinking users 243192 Dec 21 1999 Image002.jpg
-rw-r--r-- 1 blinking users 230380 Dec 21 1999 Image003.jpg
-rw-r--r-- 1 blinking users 293860 Dec 21 1999 Image004.jpg
-rw-r--r-- 1 blinking users 67652 Dec 21 1999 Image005.jpg

export FILE=page.html;echo "<HTML><BR><TITLE>Index of `pwd` </TITLE> Content of directory `pwd`<BR><BR>" >$FILE; for d in *.jpg; do echo "<A HREF=\"$d\">"$d"<BR>">>$FILE;done;echo "</A> <BR>Page last modified on `date`<BR></HTML>">>$FILE

  • Read more

killall x openbsd

Submitted by fabio on Tue, 2006-01-10 15:47.
  • bash

E` l'equivalente di killall PROC x openbsd visto che non c'e` si imposta la variabile PROC=nomeprocesso et voila`:

PROC=sleep ; for i in `find /proc -type d` ; do result=`cat $i/status 2> /dev/null` ; found=`echo $result | awk '{ print $1 }'` ; test $found = $PROC 2> /dev/null && echo $result | kill -$SIG `awk '{ print $2 }'` ; done

Lorenzo Martignoni

cdrecord + bladeenc

Submitted by fabio on Tue, 2006-01-10 15:45.
  • bash

Con il seguente comando si estrae l'immagine di un cd audio e si
ottengono 2 files: data.bin contenente i dati grezzi e toc contenente le
informazioni sullo spiazzamento e sulla durata delle singole tracce:

gianz@guybrush:cd-images$ cdrecord read-cd toc
...
gianz@guybrush:cd-images$ ls -l
total 476695
-rw------- 1 gianz users 486224256 Sep 1 23:25 data.bin
-rw------- 1 gianz users 1263 Sep 1 23:25 toc
la rigona di comando é questa:

gianz@guybrush:cd-images$ for i in `seq 1 \`grep -c TRACK toc\`` ; do dd if=data.bin skip=`grep -A 5 "Track $i"$ toc | grep data.bin | awk '{ print( $3); }' | awk -F : '{ print(int((($1*6000+$2*100+$3)*1764)/1024)); }'` count=`grep -A 5 "Track $i"$ toc | grep data.bin | awk '{ print( $4); }' | awk -F : '{ print(int((($1*6000+$2*100+$3)*1764)/1024)); }'` bs=1024 | sox -t .cdr - -t wav - | bladeenc STDIN track$i.mp3 ; done

dopo un po' di tempo questo é ció che ottengo:

  • Read more

up & lower case

Submitted by fabio on Wed, 2006-01-04 16:58.
  • bash
  • perl

Pipe che restituisce caratteri maiuscoli da minuscoli

echo ciao |perl -e 'while (<>) { print uc }'

Muovi tutti i file presenti in una dir da maiuscoli a minuscoli o viceversa ..

for i in `ls` ; do mv $i `echo $i |perl -e 'while(<>) { print lc ;}'` ; done

Muovi tutti i file presenti in una dir da maiuscoli a minuscoli o viceversaanche se contengono degli spazi (Thanks Nando) ..
for i in * ; do mv "$i" "`echo $i | perl -e 'while(<>) { print lc ;}'`" ; done

little perl search engine

Submitted by fabio on Wed, 2006-01-04 16:57.
  • bash
  • perl

Motore di ricerca per piccoli alberi html ;-)

grep -ir 'pattern' path_dove_cercare/*html|awk --field-separator=":" {'print $1;'}|perl-e '$old=""; while() { if ($_ ne $old) {print "$_"} $old=$_;}'

html strip tags

Submitted by fabio on Wed, 2006-01-04 16:54.
  • bash
  • perl

Legge tutti i files html contenuti in una directory [non scende
ricursivamente nelle sottodirectory] eliminandone i tag e li concatena in un
unico file ASCII conservando i commenti HTML.

cat *.htm |perl -e {'while () { s/<.*>//s; print }'} > output_text_file

Idem come sopra ma ricursivo ;-)

find . -iname "*.htm*" |perl -e {'while () { s/<.*>//s; print }'} > output_text_file

kill + fuser

Submitted by fabio on Wed, 2005-12-21 16:37.
  • bash

Il comando netstat (netstat -na --ip) ti rivela che hai una porta aperta (es. 515, lpd) e vuoi chiuderla?

kill -9 `fuser 515/tcp|awk {'print $2 '}`

cat $i|sed

Submitted by fabio on Wed, 2005-12-21 16:35.
  • bash

Leggi i files contenuti in una directory [in questo caso etc/bind/virtual]
e sostituisci ogni ricorrenza di 192.168.0.113 con 192.168.1.10 mettendo i
files nuovi in una directory con il nome del nuovo ip address.

for i in `ls` ;do cat $i|sed s/192.168.0.113/192.168.1.10/ > dir_192.168.1.10/$i;done

kill

Submitted by fabio on Tue, 2005-12-20 16:48.
  • bash

killa un processo ricavando l'id dal nome:

kill -9 `ps auxw |grep process_name |awk {'print $2'}`

man to lp

Submitted by fabio on Tue, 2005-12-20 15:09.
  • bash

Visualizza una manpage in Postscript, formatta a 2 pagine x A4 e manda in stampa sulla stampante lp:

man -t ls| mpage -2A| lpr -Plp

tags in Arguments

administrivia bash Debian GNU/Linux OS emacs howto perl scripts web
more tags

Navigation

  • Feedback
  • News aggregator

ICT users' rights

  • Support freedom by joining the FSF during our year-end fundraiser
  • Bilski ruling: a victory on the path to ending software patents
  • FSF Releases New Version of GNU Free Documentation License
  • FSF reboots its High Priority list with a grant and call for input
  • "Avoiding Ruinous Compromises" by Richard Stallman
more

High Scalability Architecture

  • Scalability Perspectives #2: Van Jacobson – Content-Centric Networking
  • What CDN would you recommend?
  • Is Eucalyptus ready to be your private cloud?
  • Private/Public Cloud
  • Useful Cloud Computing Blogs
more

Debian Security

  • DSA-1667 python2.4
  • DSA-1666 libxml2
  • DSA-1665 libcdaudio
  • DSA-1664 ekg
  • DSA-1663 net-snmp
more

Drupal Security

  • SA-2008-069 - CCK for 5.x and 6.x - XSS vulnerabilities
  • SA-2008-068 - Localization client and Localization server - Cross site request forgery
  • SA-2008-067 - Drupal core - Multiple vulnerabilities
  • SA-2008-066 - Shindig-Integrator - Multiple vulnerabilities
  • SA-2008-065 - Node Clone - Access bypass
more

EFF

  • FBI Withdraws Unconstitutional National Security Letter After ACLU and EFF Challenge
  • EFF and Sheppard Mullin Defend Wikipedia in Defamation Case
  • Congress Must Investigate Electronic Searches at U.S. Borders
  • Betrayed MSN Music Customers Deserve More from Microsoft
  • EFF Report: FBI Slowed Terror Investigation with Improper NSL Request
more

Invent Geek

  • the ion cooler 2.0
  • the ultimate dance pad v1.0
  • thermaltake sponsors inventgeek
  • The Thermaltake MiniFridge Case Mod
  • Inventgeek gets a facelift and a butt tuck
more

 Privacy | Disclaimer | Drupal | Creative Commons

All content on this site is ditributed under Creative Commons License, each individual author is responsible for its own posts.

RoopleTheme