Re: Bash: How do I quote CR &| LF in a command?

From: Guy Waugh (guywaugh_at_hotmail.com)
Date: 08/05/04


Date: 4 Aug 2004 18:44:07 -0700

foo <foo@bar.baz> wrote in message news:<4e8Qc.87546$eM2.66256@attbi_s51>...
> Guy Waugh wrote:
>
> > Hi there,
> >
> > I want to use elinks (a text mode web browser) on a RHEL3 box to
> > access a URL on another server, but I want also to set a 'Host:'
> > header. Apparently this can be done, a la this perl script from
> > http://downloads.securityfocus.com:
> >
> > #!/usr/bin/perl --
> > # Ulf Harnhammar 2002
> > # example: ./exploit www.site1.st www.site2.st
> > # will show www.site2.st
> >
> > die "$0 hostone hosttwo\n" if @ARGV != 2;
> >
> > exec('lynx "'.
> > "http://$ARGV[0]/ HTTP/1.0\012".
> > "Host: $ARGV[1]\012\012".
> > '"');
> >
> > I haven't tested the above perl script - I'm assuming it works. As can
> > be seen, the URL part ('http://...') and the 'Host:' header are
> > separated by a carriage return character (\012).
> >
> > I want to do in bash what the above perl script does. However, I can't
> > figure out how to quote the carriage return so that it is passed
> > through to the web server in the same way that the perl script above
> > does it.
>
> ARGV=( ... )
> cr=$'\012' # see <http://www.tldp.org/LDP/abs/html/quoting.html>
>
> lynx "http://${ARGV[0]}/ HTTP/1.0${cr}Host: ${ARGV[1]}${cr}${cr}"

Thanks foo, that looks like it would work, but alas, I tested the perl
script this morning (should have done that yesterday), and it didn't
work...

I've decided to use wget to do this job, as you can give it an
argument of --header='' on the command line, which works perfectly.

Thanks for your reply too Stephane - I need the Host: header because
I'm working with LVS real servers inside the realserver network, so I
need to set the Host: header manually.

Cheers,
Guy.



Relevant Pages

  • Re: CGI scripts and MSIE
    ... Last night I put a perl script into my cgi-bin directory and gave it ... I would guess that you haven't specified in the HTML what the contents ... Most likely the other browsers have defaulted to text/html, ... What you need to do is add a header to the HTML you send back saying ...
    (uk.comp.os.linux)
  • Reading a directory and Renaming the file
    ... I've this Perl script to read all files in a directory and if it finds a ... the right directory and doesn't even look for the HPAY header. ... Use of uninitialized value in concatenation or string at ./process_f ...
    (perl.beginners)
  • Re: Perl sendmail going to spam folders?
    ... > I am using sendmail in a perl script to send a message to the email ... > is about the sendmail that makes yahoo think it is spam. ... The body is simply a sequence of characters that ... follows the header and is separated from the header by an empty line ...
    (comp.lang.perl.misc)
  • Re: OUT on XP
    ... Oh, the StdLib functions? ... All the information you need is in the stdlib .hhf header files. ... could write a PERL script to extract this information, ... you use use the HLA pattern-matching functions to do ...
    (alt.lang.asm)
  • Re: nameserver changing
    ... Re: nameserver changing: ... >> None of the machines are running their own dns servers. ... >script that will be scp'ed and executed on each host. ... >and then create one Perl script for every host. ...
    (freebsd-questions)