Problema con script ejecutando en pfsense



  • saludos a todo el grupo

    estoy ejecutando este escript….pongo el codigo:

    #!/bin/bash
    ############################################################################
    #                        GET Nets and AS by domain                        #
    #                      BASH SCRIPT FOR PFSENSE 2.3                        #
    #            BY JAVIER CASTAÑÓN - 2016 - HTTPS://JAVCASTA.COM            #
    ############################################################################
    #      uso: alojar getNetsByDomain.sh en carpeta,p.e. /tmp o /scripts      #
    #        ejecutarlo desde shell:# sh /tmp/getNetsByDomain.sh              #
    ############################################################################
    read -p 'Enter domain (foo.bar): ' INPUTDOMAIN
    LAIP=$(host -4 $INPUTDOMAIN | grep "$INPUTDOMAIN has address" | cut -d " " -f 4)
    printf "IP for $INPUTDOMAIN is $LAIP \n"
    printf "getting AS NUMBER... \n"
    ASNUMBER=$(whois -h whois.cymru.com -- "-c $LAIP" | grep -v "AS" | cut -d "|" -f 1)
    ASSTRING="AS$ASNUMBER"
    printf "ASN for $INPUTDOMAIN is $ASSTRING \n"
    whois -h whois.radb.net -- "-i origin $ASSTRING" | awk '/^route:/ {print $2;}' | sort | uniq > /tmp/thenet.tmp
    THENET=$(cat /tmp/thenet.tmp)
    printf "The nets for $INPUTDOMAIN is in file /tmp/thenet.tmp: \n"
    echo $THENET

    y me sale este error:

    [2.3.3-RELEASE][admin@pfSense.localdomain]/root: sh /tmp/as.sh
    Enter domain (foo.bar): pfsense.com
    : bad variable name
    Usage: host [-aCdilrsTvw46] [-c class] [-N ndots] [-R number]
                [-t type] [-W wait] name [server]
            -a same as -v -t ANY
            -C query SOA records from all authoritative name servers
            -c use this query class (IN, CH, HS, etc)
            -d produce verbose output, same as -v
            -i use IP6.INT for IPv6 reverse lookups
            -l list records in a zone via AXFR
            -N consider names with at least this many dots as absolute
            -R retry UDP queries this many times
            -r disable recursive query
            -s do not ignore SERVFAIL responses
            -T send query via TCP
            -t use this query type (A, AAAA, MX, etc)
            -v produce verbose output
            -w wait forever for a server reply
            -W wait this many seconds for a reply
            -4 use IPv4 only
            -6 use IPv6 only
    P for  is
    getting AS NUMBER…
    SN for  is AS
    cat: /tmp/thenet.tmp: No such file or directory
    The nets for  is in file /tmp/thenet.tmp:

    donde esta el error ......no se programar en script
    alguien que me ayude porfavor

    esta subido el archivo en la carpeta /tmp de pfsense



  • cierro el tema porque encontre el error ….........no soy programador pero al azar lo encontre:

    LAIP=$(host -4 $INPUTDOMAIN | grep "$INPUTDOMAIN has address" | cut -d " " -f 4)

    $INPUTDOMAIN de estar encerrado entre comillas



  • Hola

    Pués a mi me funciona sin comillas:

    Desde la shell, directamente:

    root@pfSense:/tmp/nevera#set INPUTDOMAIN=pfsense.com
    root@pfSense:/tmp/nevera#host -4 $INPUTDOMAIN | grep "$INPUTDOMAIN has address" | cut -d " " -f 4
    208.123.73.69
    root@pfSense:/tmp/nevera#

    Salu2


Log in to reply