Re: - leerzeichen -

From: Thomas Zastrow <chef(at)thomas-zastrow.de>
Date: Wed, 28 May 2003 17:05:58 +0200

On Wed, 28 May 2003 16:13:34 +0200
ml-eng(at)qvc.com wrote:

> hallo,
> habe hier ein problem, ich habe eine datei irgentwas.txt
>
> irgentwas.txt :
> 172.25.160.238';'SICHT02 ';'<server>';'SICHT02
> ';'00-01-03-13-f1-7d
> 172.25.160.239';'SICHT01 ';'<server>';'SICHT01
> ';'00-01-03-14-21-9c
> 172.25.160.242';'ENGSERIAL ';'<server>';'ENGSERIAL
> ';'00-01-02-f7-22-cd
> 172.25.160.249';'VIZGW01 ';'<server>';'VIZGW01
> ';'00-00-00-00-00-00
>
> ich moechte mit
>
> #!/bin/sh
> DATE=`date "+%d.%m.%Y"`
> TIME=`date "+%H:%M:%S"`
> DATA=`/bin/cat /tmp/nbtscan.inf`
> for i in $DATA
> do
> echo "'$DATE','$TIME'$i'"
> # /websystem/mysql/bin/mysql -e "INSERT INTO nbtscan VALUES
> ('','$DATE','$TIME','$i')" netstatus
> done
>
> die daten zeile fuer zeie in eine mysql datenbank speichern
> raus kommt in diesem fall
>
> '28.05.2003','16:06:11'172.25.160.238';'SICHT02'
> '28.05.2003','16:06:11'';'<server>';'SICHT02'
> '28.05.2003','16:06:11'';'00-01-03-13-f1-7'
> '28.05.2003','16:06:11'172.25.160.239';'SICHT01'
> '28.05.2003','16:06:11'';'<server>';'SICHT01'
> '28.05.2003','16:06:11'';'00-01-03-14-21-9'
> '28.05.2003','16:06:11'172.25.160.242';'ENGSERIAL'
> '28.05.2003','16:06:11'';'<server>';'ENGSERIAL'
> '28.05.2003','16:06:11'';'00-01-02-f7-22-c'
> '28.05.2003','16:06:11'172.25.160.249';'VIZGW01'
> '28.05.2003','16:06:11'';'<server>';'VIZGW01'
> '28.05.2003','16:06:11'';'00-00-00-00-00-0'
>
>
> er behandelt das file nach allen spaces als neue datensaetze, so will ich
> das nicht :)
> sollte so sein !
>
> 172.25.160.238';'SICHT02';'<server>';'SICHT02';'00-01-03-13-f1-7d
> 172.25.160.239';'SICHT01';'<server>';'SICHT01';'00-01-03-14-21-9c
> 172.25.160.242';'ENGSERIAL';'<server>';'ENGSERIAL';'00-01-02-f7-22-cd
> 172.25.160.249';'VIZGW01';'<server>';'VIZGW01';'00-00-00-00-00-00
>
> weiss wer rat ?
>
> gruss Stefan

mysqlimport koennte Dir da weiterhelfen:

http://www.mysql.com/doc/en/mysqlimport.html

Oder aber auch die "LOAD DATA INFILE"-Syntax:

http://www.mysql.com/doc/en/LOAD_DATA.html

Ist sicherlich flexibler als es ueber ein Shell-Script zu machen ;-)

Gruss,

Tom

-- 
To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Wed 28 May 2003 - 16:51:57 CEST

search this site