-5

This is concerning an old script from 2013 which some Ubuntu-Forum Users and Users at askubuntu came up with, together with me. The script is:

#!/bin/bash
awk '{
    for (i = 1; i <= NF; i++)
        if ($i ~ /^SRC=/)
            print substr($i, 5)
}' /var/log/syslog | sort -u | while read ip; 
do
    printf ' INVALID STATE ' && printf ' =.|=.|=.|= %n =.|=.|=.|=\n ' | "$ip";
    whois "$ip" >> log-002.txt;
done

Should I place a matriz here in the variable ip to make a scanable ipv6 Address? Or is this due to a new version of whois? A correction to this script will be rewarded.

Obviously the provider (unitymedia) has a new firewall which makes a whois-query impossible. Should I wait for a new update of whois? Or can this problem be solved?

The result of this script ends as follows:

INVALID STATE ./pitbull-001.sh: Zeile 8: 2a02:0908:fd60:9200:b196:36be:5aa1:b60b: command not found INVALID STATE ./pitbull-001.sh: Zeile 8: 2a02:0908:fd60:9200:ba70:f4ff:fef3:2df3: command not found INVALID STATE ./pitbull-001.sh: Zeile 8: fe80:0000:0000:0000:0a95:2aff:fe7a:bca7: command not found INVALID STATE ./pitbull-001.sh: Zeile 8: fe80:0000:0000:0000:ba70:f4ff:fef3:2df3: command not found

But whois does work when the ipv6 address is given explicitly at the command line:

whois 2a02:0908:fd60:9200:b196:36be:5aa1:b60b:

It seems as if the whois database is partially damaged, or as if somebody is prohibiting queries?

The difference is, that when making a query at homepage http://whois.net after entering the ip-numbers there into query-field, then results are not the same like when making whois-query locally at your machine.

In case the text of this thread is inappropriate, then please do adjust it to proper English. My syntax is different than your syntax. :-)

12
  • Could you add links to the original Ubuntu-Forum and askubuntu articles? Also, what is the correct output are you expecting? Finally, what is matriz (could you give an example or link)?
    – Gsxr1k
    Dec 7, 2015 at 10:26
  • I found it: the original link is askubuntu.com/questions/307041/…. That script looks like it should work with ipv6 as well as ipv4.
    – Gsxr1k
    Dec 7, 2015 at 13:41
  • @Gsxr1k - Yes true, this was the page. Thank you for the link. Think you have done it. But will wait for else suggestions. :o) Dec 7, 2015 at 19:31
  • @Gsxr1k - only modifying with an 'echo'-command is a bit too economical ... I have re-edited my question. Dec 11, 2015 at 12:14
  • @braiam - my question was explicit enough to solve it not too economically like only by an echo-command ... at whois.net the queries are different than here ... Dec 11, 2015 at 12:15

1 Answer 1

1
+100

I am not quite sure what output you are expecting (I will update this answer if it becomes clear), but the error message is caused by piping the output of printf to "$ip" on line 8, which is interpreted as a command.

The following script will not give errors, but I'm not sure if it's the output you're after:

#!/bin/bash
awk '{
    for (i = 1; i <= NF; i++)
        if ($i ~ /^SRC=/)
            print substr($i, 5)
}' /var/log/syslog | sort -u | while read ip; 
do
    printf ' INVALID STATE ' && echo "$ip";
    whois "$ip" >> log-002.txt;
done

The output will be appended to the file log-002.txt in the current directory (as it already was with your original script).

4
  • this works slightly better but script is stopping and hunging up the phone (breaks off) - it should list the traffic as in syslog ... ?! or it can be that all firms have given up knocking on the phone line ... :-) means then firewall of phone company is finally working this year. Dec 7, 2015 at 12:02
  • there is no complete archive available at askubuntu.com - otherwise I could be more elaborately. Dec 7, 2015 at 12:09
  • This is the post: askubuntu.com/questions/307041/…. I suggest you use their script, which will work with ipv6 as well as ipv4.
    – Gsxr1k
    Dec 7, 2015 at 13:22
  • as you can see this question is actualized for 16.04 here, after I edited the question a bit (about /etc/sysctl.conf - file) : askubuntu.com/questions/307041/… Jun 22, 2016 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .