Re: Capturing output (domain name) of wget after http redirect



On Wed, 26 Sep 2007 06:51:51 -0700, JamesG wrote:

On Sep 26, 2:32 pm, Icarus Sparry <use...@xxxxxxxxxxxxxxxxx> wrote:

There are now 2 remaining problems.
Because there are multiple hops (redirects) I get a list of several
entries.

For example:
Connecting towww.perfiliate.com|62.190.8.171|:80... connected.
Connecting to ad.uk.doubleclick.net|209.62.178.57|:80... connected.
Connecting to ad.doubleclick.net|65.205.8.52|:80... connected.
Connecting to ad.doubleclick.net|65.205.8.52|:80... connected.
Connecting to fls.doubleclick.net|216.73.87.48|:80... connected.
Connecting towww.theaa.com|213.225.133.206|:80... connected.

I need it to only select the last entry. The final problem is
seperating
www.theaa.comout. I think I can do this with "sed".

Any ideas on the first problem? Thanks

"tail -1", or if you are going to be using sed anyhow

sed -n '$s/Connecting to \([^|]*\)|.*/\1/p'

Thanks for the help.

Using that sed command doesn't seem to do the trick :(

I'm running: wget -S --spider http://www.google.com 2>&1 | sed -n '$s/
Connecting to \([^|]*\)|.*/\1/p'
Am I missing something stupid?

Thanks

I was rather expecting you to keep the grep in the command

wget -S --spider http://www.google.com 2>&1 >/dev/null |
grep '^Connecting to' |
sed -n '$s/Connecting to \([^|]*\)|.*/\1/p'


.



Relevant Pages

  • Compromised - Port 1524
    ... cat /proc/cpuinfo' ... grep rsdh /etc/inetd.conf; ... tail /etc/rc.d/rc.local; ... chmod 755 synscan; ...
    (Incidents)
  • Re: Having trouble with tail -f standard input
    ... log file on a UNIX server. ... the tail -f command. ... non-blocking I/O in your Python program, but I don't think it will be ... grep from within your program, ...
    (comp.lang.python)
  • Re: *nice* maillog output
    ... > This one never ends the tail output, so it never releases control to the ... Grep is waiting for the end of the input before it ... With sufficient input for tail, resulting in sufficient output to fill ... then it's a buffer problem. ...
    (Fedora)
  • Re: Compromised - Port 1524
    ... > dmesg | grep -i promi; ... > ps auwx| grep named; ... > chmod 755 synscan; ... > tail 216.out; ...
    (Incidents)
  • Re: strict grep when patterns are presented on standard input
    ... >> standard input but both are presented on the standard output ... I can add just another sed command to the pipe ... > Dum question, now I know it. ... -w option of grep will do it. ...
    (comp.unix.shell)

Loading