Skip to content

Instantly share code, notes, and snippets.

@leohackin
Last active September 24, 2015 21:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save leohackin/811573 to your computer and use it in GitHub Desktop.
Save leohackin/811573 to your computer and use it in GitHub Desktop.
Script para rastreamento contínuo de encomenda nos Correios via linha de comando for Mac.
#!/bin/bash
# Created by Léo Hackin (leohackin at gmail.com), Jan 2011
# This file is free software. You are free to use this file in any way you like
# However, if you change it you should note in this file that you did and who
# you are, you also need to change the version string if you do. That way
# I will not get support questions for software that is not entirely mine.
# rastreia_encomenda_correios v.0.1a for mac
# Script para rastreamento de encomenda dos Correios.
# O script verifica a cada 2 minutos se houve alguma
# movimentacao: em caso afirmativo, ele alerta o usuario
# com uma mensagem e abre o navegador para exibir o rastreamento
#
# Uso
#
# Copie o código e salve em um arquivo no local e com o nome da sua preferencia.
# Após salvar, dê um chmod +x nomearquivo
#
# Para iniciar o rastreamento, execute o comando como abaixo:
#
# ./<nomedoscript> codigo_da_sua_encomenda
# ./rastreia_encomenda CP123456789US (exemplo)
#
if [ "$1" == "" ]
then
echo "Informe o codigo da encomenda"
exit 666
fi
while true
do
curl -o novorastreamento.txt -d "P_LINGUA=001&P_TIPO=001&P_COD_UNI=$1" http://websro.correios.com.br/sro_bin/txect01$.QueryList?
V=`diff -uNr antigorastreamento.txt novorastreamento.txt`
if [ "$V" != "" ]
then
/usr/bin/osascript -e 'tell application "Finder"' -e "activate" -e "display dialog \"Rastreamento mudou! ;)\"" -e 'end tell'
if [ "$?" == "0" ]
then
open "http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_LINGUA=001&P_TIPO=001&P_COD_UNI=$1"
fi
curl -o antigorastreamento.txt -d "P_LINGUA=001&P_TIPO=001&P_COD_UNI=$1" http://websro.correios.com.br/sro_bin/txect01$.QueryList?
fi
sleep 120
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment