Im back at this:
Code:
Code:
#!/bin/sh
#set -xo
# This script will format the output of tail -f dnsmasq.log > logfile
# where logfile is the output of tail -f dnsmasq.log
# 1. extract records whose contents contain the word "query"
# 2. output only the domain name
# 3. sort file for unique contents to elimnate duplicates
# 4. save to $1_output
#
# Parameters Passed
# $1 = provide the name of the source file when running the script
# e.g. ./getdomainnames.sh logfile
#
source_file=/tmp/mnt/absolution/adblocking/logs/$1
output_file=$source_file"_output"
cat $source_file | grep query | grep 192.168.22.152 | awk '{ print $6 }' | sort -u > $output_file
#cat $source_file | grep cached | awk '{ print $6 }' | sort -u > $output_file
But when I run it, it says error on line 1 : no code. If I try to run
Code:
tail -f dnsmasq.log > logfile
it just crashes my WinSCP. However when I log back in, I see a logfile created next to dnsmasq.log. I do not know why the source file in your code is referring to adblocking? I have changed that to just this logfile at /jffs/logs/
Here is the exact code of my getdomainnames.sh script in case its wrong.
Code:
Code:
#!/bin/sh
#set -xo
# This script will format the output of tail -f dnsmasq.log > logfile
# where logfile is the output of tail -f dnsmasq.log
# 1. extract records whose contents contain the word "query"
# 2. output only the domain name
# 3. sort file for unique contents to elimnate duplicates
# 4. save to $1_output
#
# Parameters Passed
# $1 = provide the name of the source file when running the script
# e.g. ./getdomainnames.sh logfile
#
source_file=/jffs/logs/$1
output_file=$source_file"_output"
cat $source_file | grep query | grep 192.168.1.175 | awk '{ print $6 }' | sort -u > $output_file
#cat $source_file | grep cached | awk '{ print $6 }' | sort -u > $output_file
And when I run it
/jffs/scripts$ sh getdomainnames.sh logfile
getdomainnames.sh: line 1: Code:: not found
Still this error.
dnsmasq.log seems to be populated now, but not by much to be honest, just a few DHCP
requests and stuff like that.