Cálculo com endereço IP no Excel – parte 2
Para conversão da notação em barra (/23) para máscara (255.255.254.0), copie e cole o bloco abaixo no Excel na célula A1:
192.168.32.160/23
Mask Calculation
=RIGHT(A1;LEN(A1)-FIND("/";A1))
=2^32-(2^(32-A3))
=DEC2HEX(A4;8 )
=MID($A$5;1;2)
=MID($A$5;3;2)
=MID($A$5;5;2)
=MID($A$5;7;2)
=HEX2DEC(A6)&"."&HEX2DEC(A7)&"."&HEX2DEC(A8)&"."&HEX2DEC(A9)
=-HEX2DEC(A6)-1
=-HEX2DEC(A7)-1
=-HEX2DEC(A8)-1
=-HEX2DEC(A9)-1
=RIGHT(DEC2HEX(A11);2)
=RIGHT(DEC2HEX(A12);2)
=RIGHT(DEC2HEX(A13);2)
=RIGHT(DEC2HEX(A14);2)
=HEX2DEC(A15)&"."&HEX2DEC(A16)&"."&HEX2DEC(A17)&"."&HEX2DEC(A18 )
A célula A10 mostrará a máscara correspondente e a célula 19, o wildcard.
Cisco: Key Sequences for Command Edit and Recall
| Keyboard Command | What You Get |
| Up arrow or Ctrl-p | This displays the most recently used command. If it is pressed again, the next most recent command appears until the history buffer is exhausted. (The p stands for previous.) |
| Down arrow or Ctrl-n | If you have gone too far back into the history buffer, these keys will go forward to the more recently typed commands. (The n is for next.) Left arrow or Ctrl-b This moves the cursor backward in the currently displayed command without deleting characters. (The b stands for back.) |
| Right arrow or Ctrl-f | This moves the cursor forward in the currently displayed command without deleting characters. (The f stands for forward.) |
| Backspace | This moves the cursor backward in the currently displayed command, deleting characters. |
| Ctrl-a | This moves the cursor directly to the first character of the currently displayed command. |
| Ctrl-e | This moves the cursor directly to the end of the currently displayed command. |
| Esc-b | This moves the cursor back one word in the currently displayed command. |
| Esc-f | This moves the cursor forward one word in the currently displayed command. |
| Ctrl-r | This creates a new command prompt, followed by all the characters typed since the last command prompt was written. This is particularly useful if system messages confuse the screen and it is unclear what you have typed so far. |
Bash prompt – PS1
Para mostrar o diretório atual e o hostname no prompt do bash:
bash$ PS1='\r\n[\w]\r\n\h> ' [~/dir/abc] thehost>
Cisco: Envio de rotas através de tunel – GRE + OSPF
ROUTER A – Anuncia a rota default:
! interface Tunnel0 description Tunnel to RouterB ip unnumbered Loopback0 ip tcp adjust-mss 1436 ip ospf 50 area 0 tunnel source Loopback0 tunnel destination 10.2.2.2 ! router ospf 50 router-id 10.1.1.1 log-adjacency-changes passive-interface default no passive-interface Tunnel0 default-information originate !
ROUTER B – Recebe a rota defaul via ospf:
! interface Tunnel0 description Tunnel to RouterB ip unnumbered Loopback0 ip tcp adjust-mss 1436 ip ospf 50 area 0 tunnel source Loopback0 tunnel destination 10.1.1.1 ! router ospf 50 router-id 10.2.2.2 log-adjacency-changes passive-interface default no passive-interface Tunnel0 distance 1 !
Distance = 1 faz com que a rota default recebida por este processo OSPF tenha preferência sobre qualquer outro protocolo.
Não foi usado o comando ‘keepalive’ no tunel pois há o keepalive (hello packets) do ospf.
Cálculo com endereço IP no Excel
Para somar (ou subtrair) valor de um endereço IP:
=LEFT(A1;FIND("x";Substitute(A1;".";"x";3))-1)&"."
&(MID(A1;FIND("x";Substitute(A1;".";"x";3))+1;3) + 1)
Onde A1 é a celula com o valor original e o valor a ser somado é o último número da fórmula (no exemplo, +1).
fonte: Chip Pearson, 2000-08-15 extraído de http://www.mvps.org/dmcritchie/excel/sorttcp.htm
Download automático do Estadão [pdf]
Script shell para download automático do jornal O Estado de S. Paulo (é necessário ser assinante para obter o cookie descrito abaixo).
Primeiro deve-se logar em jpdf.estado.com pegar a chave do cookie User (exemplo: 2oxNTY2FmM2FwcmFkb0DnbYgubm8cHJhZG9aZ30fDE1M14Lm5ldZ%3D%3D).
Nota: para obter o cookie no Firefox, entre em Ferramentas > Opções > Privacidade > Mostrar Cookies e filtrar por estado.com.br e copiar o conteúdo do cookie “User”.
Criar o seguinte shell script (pode ser rodado no Windows via Cygwin), trocando o valor da variável cookie e do proxy (caso não use proxy, remova o flag –proxy do wget):
export http_proxy="http://10.1.1.1:8000"
cookie='xcSFSfsfsdfSDF3253'
dd=`date +%d`
mm=`date +%m`
yyyy=`date +%Y`
index="http://jpdf.estado.com.br/menupdfi.php?E=SP&D=$dd/$mm/
$yyyy&A=/estadopdf/sp/paginas/$yyyy/$mm/$dd/A01.pdf"
rm index.txt
/cygdrive/c/temp/wget/wget -nc -k -S -U Mozilla --proxy
--header "Cookie: User=$cookie " -O index.txt $index
if [ ! -f index.txt ]; then exit 1; fi
l=`gawk 'BEGIN {FS="\""} /option VALUE="\/estadopdf/ { print $2 }' index.txt`
for x in $l; do
# Ignora os classificados
if [ ${x%01.pdf} -eq "Cl" ]; then continue; fi
# Ignora o Guia
if [ ${x%01.pdf} -eq "Q" ]; then continue; fi
y=http://jpdf.estado.com.br${x%01.pdf}
i=1
flag=0
while [ $i -lt 40 ]; do
filename=`printf "%s%02d.pdf\n" $y $i`
echo "=================================================================="
echo $filename
echo "=================================================================="
/cygdrive/c/temp/wget/wget -P estado -nc -k -S -U Mozilla --proxy
--header "Cookie: User=$cookie " $filename
if [ $? -eq 1 ]; then
let flag=flag+1
if [ $flag -gt 1 ]; then
flag=0
echo "Proximo caderno..."; break;
fi
fi
sleep 1
let i=i+1
done
done
Confira o código aqui.
Para juntar todos os pdfs em um único arquivo, usar o PDF Split and Merge (http://www.pdfsam.org/):
dd=`date +%d`
mm=`date +%m`
yyyy=`date +%Y`
echo "Concatenando os arquivos em ./Estado${yyyy}${mm}${dd}.pdf..."
ls -m estado/*.pdf | tr -d ' ' > lista.csv
java -jar ./pdfsam-basic/lib/pdfsam-console-0.7.3.jar -overwrite
-compressed -l lista.csv
-o ./Estado${yyyy}${mm}${dd}.pdf concat
Greasemonkey – Site www.estadao.com.br – Mudança na cor da fonte
Para mudar a cor da fonte das notícias do site www.estadao.com.br, usando o Firefox add-on Greasemonkey, use o seguinte script:
// ==UserScript==
// @author Adriano P.
// @name AjusteCor
// @namespace http://www.estadao.com.br/
// @description Muda a cor da fonte de www.estadao.com.br
// @include http://www.estadao.com.br/*
// ==/UserScript==
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('#corpoNoticia, #corpoNoticia p { color: #000 !important; }');
A cor definida foi a preta (em color: #000).
Cisco: Switch between Telnet Sessions
You can switch between sessions by escaping one session and resuming a previously opened session, as follows:
Step 1 Escape out the current session by pressing Ctrl-^ X and return to the EXEC prompt.
Step 2 List the open sessions using the where command. All open sessions associated with the current terminal line are displayed.
Step 3 Type the resume command and the session number to make the connection.
You can also resume the previous session by pressing the Return key.
source: http://cco.cisco.com/en/US/products/sw/iosswrel/ps1818/products_connection_guide_chapter09186a00800805db.html#xtocid1616712
Cisco login script
Script em expect para login automático em equipamentos Cisco (troque o username e a senha):
#!/usr/local/bin/expect spawn telnet $argv expect "Username:" send "username\r" expect "Password:" send "*******\r" expect ">" send "enable\r" expect "Password:" send "********\r" send "term mon\r" interact
Deixe um comentário
Deixe um comentário
Deixe um comentário
