bash & sed & und ich bin zu dappig
Hallo zusammen,
eigentlich hat alles ganz harmlos angefangen und ich wollte hier was
leidiges mal automatisieren :)
Jetzt sitz ich schon seit der zehne dran und beiß gleich in meine
Tastatur.
Ich möchte an sich für jede Zeile ein echo durchführen, aber das will
ums xxx nicht - er machts immer für jede Zeile oder für alle und ich
steige nicht durch - egal ob mit hochkommatas etc...
Hier erstmal, das was funktioniert
# cat dwtrans.sh
#!/bin/sh
HOST=`cat /etc/nagios2/conf.d/test.cfg | sed -n '/host_name/p' | cut -b
41-99 | tail -1`
SRV=` cat /etc/nagios2/conf.d/test.cfg | sed -n '/service_description/p'
| cut -b 41-99`
for i in "$SRV"
do
echo "$i"
done
exit 0
--> bringt den Output den ich möchte
---------schnipp----
sh dwtrans.sh
HTTP - WebMail
HTTP - Joomla
Load
Users
Procs Total
Procs Zombie
IP Packets IN
IP Packets OUT
IP Bytes OUT
IP Bytes IN
IP Errors OUT
IP Errors IN
Memory Free
-----------------------
Dann dachte ich, dass ich da einfach n echo reinklemme und mir
vorherigen da reinschreiben lasse..
cat dwtrans.sh
#!/bin/sh
HOST=`cat /etc/nagios2/conf.d/test.cfg | sed -n '/host_name/p' | cut -b
41-99 | tail -1`
SRV=` cat /etc/nagios2/conf.d/test.cfg | sed -n '/service_description/p'
| cut -b 41-99`
for i in $SRV
do
echo "{{http://domain.de/pnp/index.php?display=image&srv=
$i&host=testbock&type=traffic&view=2&.png?nocache}}"
done
exit 0
Output:
sh dwtrans.sh
{{http://domain.de/pnp/index.php?display=image&srv=HTTP&host=testboc&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=-&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=WebMail&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=HTTP&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=-&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=Joomla&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=Load&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=Users&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=Procs&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=Total&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=Procs&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=Zombie&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=IP&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=Packets&host=testbock&type=traffic&view=2&.png?nocache}}
{{http://domain.de/pnp/index.php?display=image&srv=IN&host=testbock&type=traffic&view=2&.png?nocache}}
----> DA MACHT ER ES FÜR JEDES ZEICHEN
Ich habe schon mit while gespielt und kommas und keine ahnung was noch
probiert und blix net :(
Ich bräuchte das so:
{{http://domain.de/pnp/index.php?display=image&srv=HTTP
+-+WebMail&host=testbock&type=traffic&view=2&.png?nocache}}
Also für jede Zeile. Wo liegt denn der Fehler?
Grüße
Thomas
Reply to: