Re: [CentOS] Help with at Bash script
if i understood cerrectly,you need that: domain=$(tcpdump -l -n -e port 53 | awk '{if ($14 ~ /A.*?/) print $15}') while read line do echo $line done < $domain On 3 December 2014 at 08:29, Hal Wigoda wrote: > What is domain, BTW? > > (Sent from iPhone, so please accept my apologies in advance for any > spelling or grammatical errors.) > > > On Dec 2, 2014, at 12:05 PM, James B. Byrne > wrote: > > > > I am attempting to get a script borrowed from DJB to work on my > CentOS-6.6 > > box. Simplified it looks like this: > > > > tcpdump -l -n -e port 53 \ > > | awk '{if ($14 ~ /A.*?/) print $15}' \ > > | while read domain ; do echo $domain ; done ; > > > > The sticking point is the 'while read' construct. Run just as 'tcpdum | > awk' > > I get this: > > > > english.stackexchange.com. > > www.urbandictionary.com. > > www.urbandictionary.com. > > www.urbandictionary.com. > > www.urbandictionary.com. > > api.mywot.com. > > a.udimg.com. > > a.udimg.com. > > fonts.googleapis.com. > > . . . > > > > Run with the 'while read $domain ; do echo ' pipe nothing appears > whatsoever. > > What am I doing wrong? > > > > -- > > *** E-Mail is NOT a SECURE channel *** > > James B. Byrnemailto:byrn...@harte-lyne.ca > > Harte & Lyne Limited http://www.harte-lyne.ca > > 9 Brockley Drive vox: +1 905 561 1241 > > Hamilton, Ontario fax: +1 905 561 0757 > > Canada L8E 3C3 > > > > ___ > > CentOS mailing list > > CentOS@centos.org > > http://lists.centos.org/mailman/listinfo/centos > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos > ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Help with at Bash script
Never used that construct in this context. On Tue, Dec 2, 2014 at 11:07 PM, Keith Keller wrote: > On 2014-12-03, Hal Wigoda wrote: >> You have to do >> cat domain >> in back tiks >> >> instead of read domain. > > This is an error you can't blame on your device. domain is not a file, > but a bash variable. read takes stdin (which is what the OP's snippet > is doing) and populates the named variable(s) (domain in this case). > > --keith > > > -- > kkel...@wombat.san-francisco.ca.us > > > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos -- - Hal Wigoda Chicago ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Help with at Bash script
On 2014-12-03, Hal Wigoda wrote: > You have to do > cat domain > in back tiks > > instead of read domain. This is an error you can't blame on your device. domain is not a file, but a bash variable. read takes stdin (which is what the OP's snippet is doing) and populates the named variable(s) (domain in this case). --keith -- kkel...@wombat.san-francisco.ca.us ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Help with at Bash script
What is domain, BTW? (Sent from iPhone, so please accept my apologies in advance for any spelling or grammatical errors.) > On Dec 2, 2014, at 12:05 PM, James B. Byrne wrote: > > I am attempting to get a script borrowed from DJB to work on my CentOS-6.6 > box. Simplified it looks like this: > > tcpdump -l -n -e port 53 \ > | awk '{if ($14 ~ /A.*?/) print $15}' \ > | while read domain ; do echo $domain ; done ; > > The sticking point is the 'while read' construct. Run just as 'tcpdum | awk' > I get this: > > english.stackexchange.com. > www.urbandictionary.com. > www.urbandictionary.com. > www.urbandictionary.com. > www.urbandictionary.com. > api.mywot.com. > a.udimg.com. > a.udimg.com. > fonts.googleapis.com. > . . . > > Run with the 'while read $domain ; do echo ' pipe nothing appears whatsoever. > What am I doing wrong? > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrnemailto:byrn...@harte-lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Help with at Bash script
You have to do cat domain in back tiks instead of read domain. (Sent from iPhone, so please accept my apologies in advance for any spelling or grammatical errors.) > On Dec 2, 2014, at 12:05 PM, James B. Byrne wrote: > > I am attempting to get a script borrowed from DJB to work on my CentOS-6.6 > box. Simplified it looks like this: > > tcpdump -l -n -e port 53 \ > | awk '{if ($14 ~ /A.*?/) print $15}' \ > | while read domain ; do echo $domain ; done ; > > The sticking point is the 'while read' construct. Run just as 'tcpdum | awk' > I get this: > > english.stackexchange.com. > www.urbandictionary.com. > www.urbandictionary.com. > www.urbandictionary.com. > www.urbandictionary.com. > api.mywot.com. > a.udimg.com. > a.udimg.com. > fonts.googleapis.com. > . . . > > Run with the 'while read $domain ; do echo ' pipe nothing appears whatsoever. > What am I doing wrong? > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrnemailto:byrn...@harte-lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Help with at Bash script
On Tue, Dec 2, 2014 at 1:19 PM, Alexander Dalloz wrote: > Am 02.12.2014 um 19:05 schrieb James B. Byrne: >> >> I am attempting to get a script borrowed from DJB to work on my CentOS-6.6 >> box. Simplified it looks like this: >> >> tcpdump -l -n -e port 53 \ >>| awk '{if ($14 ~ /A.*?/) print $15}' \ >>| while read domain ; do echo $domain ; done ; >> >> The sticking point is the 'while read' construct. Run just as 'tcpdum | >> awk' >> I get this: >> >> english.stackexchange.com. >> www.urbandictionary.com. >> www.urbandictionary.com. >> www.urbandictionary.com. >> www.urbandictionary.com. >> api.mywot.com. >> a.udimg.com. >> a.udimg.com. >> fonts.googleapis.com. >> . . . >> >> Run with the 'while read $domain ; do echo ' pipe nothing appears >> whatsoever. >> What am I doing wrong? Works for me as is. You just have to wait for your pipe buffer to fill so the output is bursty. -- Les Mikesell lesmikes...@gmail.com ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Help with at Bash script
Am 02.12.2014 um 20:47 schrieb Tony Schreiner: while read domain; do > echo ${domain} >done < <(tcpdump -l -n -e port 53 | awk '{if ($14 ~ /A.*?/) print $15}') [ ... ] >Alexander > If not a typo in the message, your mistake, and I do it all the time, is using while read $domain instead of while read domain Tony Tony, no, "while read $domain" is wrong. Alexander ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Help with at Bash script
On Tue, Dec 2, 2014 at 2:19 PM, Alexander Dalloz wrote: > Am 02.12.2014 um 19:05 schrieb James B. Byrne: > >> I am attempting to get a script borrowed from DJB to work on my CentOS-6.6 >> box. Simplified it looks like this: >> >> tcpdump -l -n -e port 53 \ >>| awk '{if ($14 ~ /A.*?/) print $15}' \ >>| while read domain ; do echo $domain ; done ; >> >> The sticking point is the 'while read' construct. Run just as 'tcpdum | >> awk' >> I get this: >> >> english.stackexchange.com. >> www.urbandictionary.com. >> www.urbandictionary.com. >> www.urbandictionary.com. >> www.urbandictionary.com. >> api.mywot.com. >> a.udimg.com. >> a.udimg.com. >> fonts.googleapis.com. >> . . . >> >> Run with the 'while read $domain ; do echo ' pipe nothing appears >> whatsoever. >> What am I doing wrong? >> > > while read domain; do > echo ${domain} > done < <(tcpdump -l -n -e port 53 | awk '{if ($14 ~ /A.*?/) print $15}') > > The "echo ${domain}" part is certainly just a simplification of a more > complex command to run on the variable. Else it would be pointless as awk > is printing out the domain field 15. > > Alexander > If not a typo in the message, your mistake, and I do it all the time, is using while read $domain instead of while read domain Tony ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Help with at Bash script
Am 02.12.2014 um 19:05 schrieb James B. Byrne: I am attempting to get a script borrowed from DJB to work on my CentOS-6.6 box. Simplified it looks like this: tcpdump -l -n -e port 53 \ | awk '{if ($14 ~ /A.*?/) print $15}' \ | while read domain ; do echo $domain ; done ; The sticking point is the 'while read' construct. Run just as 'tcpdum | awk' I get this: english.stackexchange.com. www.urbandictionary.com. www.urbandictionary.com. www.urbandictionary.com. www.urbandictionary.com. api.mywot.com. a.udimg.com. a.udimg.com. fonts.googleapis.com. . . . Run with the 'while read $domain ; do echo ' pipe nothing appears whatsoever. What am I doing wrong? while read domain; do echo ${domain} done < <(tcpdump -l -n -e port 53 | awk '{if ($14 ~ /A.*?/) print $15}') The "echo ${domain}" part is certainly just a simplification of a more complex command to run on the variable. Else it would be pointless as awk is printing out the domain field 15. Alexander ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
[CentOS] Help with at Bash script
I am attempting to get a script borrowed from DJB to work on my CentOS-6.6 box. Simplified it looks like this: tcpdump -l -n -e port 53 \ | awk '{if ($14 ~ /A.*?/) print $15}' \ | while read domain ; do echo $domain ; done ; The sticking point is the 'while read' construct. Run just as 'tcpdum | awk' I get this: english.stackexchange.com. www.urbandictionary.com. www.urbandictionary.com. www.urbandictionary.com. www.urbandictionary.com. api.mywot.com. a.udimg.com. a.udimg.com. fonts.googleapis.com. . . . Run with the 'while read $domain ; do echo ' pipe nothing appears whatsoever. What am I doing wrong? -- *** E-Mail is NOT a SECURE channel *** James B. Byrnemailto:byrn...@harte-lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos