Bash Regex

kevkev

Erfahrenes Mitglied
Hallo,

Folgendes Problem:
Ich bekomme mittels curl einen Header zugeschickt, der eine "Location" Angabe enthält:
Code:
HTTP/1.1 100 Continue

HTTP/1.1 302 Found
Date: Mon, 09 Jan 2006 18:59:07 GMT
Server: Apache/2.0.54 (Debian GNU/Linux) PHP/5.0.5-Debian-0.8~sarge1 mod_ssl/2.0.54 OpenSSL/0.9.7e
X-Powered-By: PHP/5.0.5-Debian-0.8~sarge1
Set-Cookie: clanguage=img_us; expires=Wed, 08 Feb 2006 18:59:08 GMT; path=/; domain=.11mbit.in
Set-Cookie: PHPSESSID=7d1d0a03a08d2a47e0256eb8af5dc819; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: index.php?123=test&456=test2
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1

Meine Frage:
Wie bekomme Ich denn nun aus der Variable, die die HeaderInfos enthält, die "Location" Angabe raus?

Hat da jemand eine Idee?

Gruß Kevin
 
Hi,

mhh, ich habe das nun so gemacht:
Code:
              curl -F "file=@lol.txt;type=text/plain" "http://123.de" -D tmp
              echo `cat tmp` | grep Location | awk -F" " '{ print $2 }'

Die Datei tmp enthält dann folgenden Inhalt:
Code:
HTTP/1.1 100 Continue^M
^M
HTTP/1.1 302 Found^M
Date: Mon, 09 Jan 2006 19:53:03 GMT^M
Server: Apache/2.0.54 (Debian GNU/Linux) PHP/5.0.5-Debian-0.8~sarge1 mod_ssl/2.0.54 OpenSSL/0.9.7e^M
X-Powered-By: PHP/5.0.5-Debian-0.8~sarge1^M
Set-Cookie: clanguage=img_us; expires=Wed, 08 Feb 2006 19:53:03 GMT; path=/; domain=.11mbit.in^M
Set-Cookie: PHPSESSID=b62ac60cf3a610c4fc561d4a96d79ad6; path=/^M
Expires: Thu, 19 Nov 1981 08:52:00 GMT^M
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0^M
Pragma: no-cache^M
Location: index.php?123=456
Transfer-Encoding: chunked^M
Content-Type: text/html; charset=ISO-8859-1^M
^M

Denn curl gibt die headerinfos irgendwie nicht direkt in die Bash aus.

Aber hier wird mir nur "100" ausgegeben.

Gruß Kevin
 
Zurück