~mdkcore/dotbins

dotbins/curreios -rwxr-xr-x 1.9 KiB
2559c86bRodrigo Oliveira [power] Use loginctl instead of pm-* 1 year, 9 months ago
                                                                                
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
#!/bin/sh
################################################################################
# This script was created by: MDK - mdkcore@qtrnn.io                           #
# https://qtrnn.io                                                             #
# Jul 11 2016                                                                  #
# Last update on Aug 20 2010                                                   #
#                                                                              #
# Simple script to get information from shipping from Correios                 #
#                                                                              #
# Depends on: w3m or lynx to display info                                      #
################################################################################

# setting up
SEPARATOR=" ─────────────────────────────────────────────────────────────────────────────"
URL="https://www.websro.com.br/detalhes.php?P_COD_UNI="

W3M="w3m -T text/html -dump -I latin1 -O utf-8"
LYNX="lynx -dump -nolist -assume_charset=latin1 -display_charset=utf-8 -stdin"
CMD=$W3M

exists=`which w3m &> /dev/null; echo $?`
# w3m not found, try lynx
if [[ $exists != 0 ]]
then
    exists=`which lynx &> /dev/null; echo $?`

    # lynx not found, fail
    if [[ $exists == 0 ]]
    then
        CMD=$LYNX
    else
        echo "w3m nor lynx were found! Install one of them to be able to run this script"
        exit
    fi
fi

# run this thing
for cod in "$@"
do
    ret=`curl -sS $URL$cod | sed -n "/<table/,/<\/table>/Ip"`
    out=$ret

    # check if we have some useful info
    if [ -z "$ret" ]
    then
        out="Wrong tracking code or no information right now"
    fi

    echo "$SEPARATOR"
    echo "<center>$cod</center>" $out | $CMD
done