Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ksh-Skript. Ich verzweifel fast. [solved]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum
View previous topic :: View next topic  
Author Message
tazinblack
Veteran
Veteran


Joined: 23 Jan 2005
Posts: 1146
Location: Baden / Germany

PostPosted: Thu Jul 17, 2008 1:16 pm    Post subject: ksh-Skript. Ich verzweifel fast. [solved] Reply with quote

Hallo zusammen,

ich hab hier ein kleines ksh-Skript, welches leider nicht tut was ich möchte.
Im Prinzip soll es per SSH vom Storage eine Liste von snapshots holen und diese dann wiederum über SSH einzeln öschen :

Code:

#!/bin/ksh
...

  ${SSH} ${FILERECHT} snap list ${VOLNAMEECHT} | awk -F'DBSNAP' ' { print $2}' | grep ${DAY2DEL} | \
  while read SNAPSHOT; do
    echo "  Loesche Snapshot : DBSNAP${SNAPSHOT}"
    ${SSH} ${FILERECHT} snap delete ${VOLNAMEECHT} "DBSNAP${SNAPSHOT}"
  done

...


Das tolle daran ist, wenn ich die Zeile
Code:
${SSH} ${FILERECHT} snap delete ${VOLNAMEECHT} "DBSNAP${SNAPSHOT}"
auskomentiere, dann zeigt er mir alle vorhandenen Snapshots an.
Wenn ich diese aber einkomentiert ausführe, löscht es den ersten Snapshot und bricht dann ab.
Als Returncode erhalte ich aber 0.
Die Variablen werden übrigens weiter oben gesetzt. Im Prinzip funktioniert es ja auch, bloß dass es nach dem ersten Ausführen des ssh abbricht.
Hab auch schon versucht den ssh mit -t oder -T auszuführen. Bringt aber auch nichts.

Also das Ganze noch mal als Ausgabe :

ohne den SSH :
Code:

./reorg_snap
Wochentag : Do
Tag zum Loeschen: Fr
------------------------------------------
Hole snapshotliste von st23x90x21

  Loesche Snapshot : DBSNAP-Fr-11.07.08-13:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-12:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-11:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-10:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-09:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-08:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-07:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-06:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-05:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-04:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-03:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-02:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-01:00:00
  Loesche Snapshot : DBSNAP-Fr-11.07.08-00:00:00


mit SSH :
Code:
./reorg_snap
Wochentag : Do
Tag zum Loeschen: Fr
------------------------------------------
Hole snapshotliste von st23x90x21

  Loesche Snapshot : DBSNAP-Fr-11.07.08-13:00:00
deleting snapshot...


Hat da jemand nen Tipp?
Wäre Euch sehr dankbar.
_________________
Gruß / Regards
tazinblack
_______________________________________________________
what's the point in being grown up if you can't be childish sometimes


Last edited by tazinblack on Thu Jul 17, 2008 2:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
69719
l33t
l33t


Joined: 20 Sep 2004
Posts: 865

PostPosted: Thu Jul 17, 2008 1:57 pm    Post subject: Reply with quote

Versuch es mal mit

Code:

#!/bin/ksh
...

  for SNAPSHOT in $(${SSH} ${FILERECHT} snap list ${VOLNAMEECHT} | awk -F'DBSNAP' ' { print $2}' | grep ${DAY2DEL}); do
    echo "  Loesche Snapshot : DBSNAP${SNAPSHOT}"
    ${SSH} ${FILERECHT} snap delete ${VOLNAMEECHT} "DBSNAP${SNAPSHOT}"
  done

...
Back to top
View user's profile Send private message
tazinblack
Veteran
Veteran


Joined: 23 Jan 2005
Posts: 1146
Location: Baden / Germany

PostPosted: Thu Jul 17, 2008 2:15 pm    Post subject: Reply with quote

Hey super, das geht! :lol:

Das hab ich schon öfters gedacht, dass while-Schleifen in der ksh nicht immer zuverlässig funktionieren. :cry:
Danke für die schnelle Antwort!
_________________
Gruß / Regards
tazinblack
_______________________________________________________
what's the point in being grown up if you can't be childish sometimes
Back to top
View user's profile Send private message
69719
l33t
l33t


Joined: 20 Sep 2004
Posts: 865

PostPosted: Thu Jul 17, 2008 2:41 pm    Post subject: Reply with quote

Dein script führt snap list aus, gibt die Ausgabe an die Pipe weiter, snap read wird angehalten und das snap delete ausgeführt. Da der snap list aber zu dem zeitpunkt immernoch nicht beendet sondern nur angehalten wurde damit die Daten über die pipe verarbeitet werden konnten wird es wohl irgendwie ein Problem damit haben.

Meine lösung holt erstmal die ganze Ausgabe und geht dann das ganze schritt für schritt durch.
Back to top
View user's profile Send private message
Evildad
Guru
Guru


Joined: 15 Apr 2004
Posts: 475

PostPosted: Thu Jul 17, 2008 4:41 pm    Post subject: Reply with quote

Interessehalber...

Welchen NetApp Filer setzt ihr ein?
Back to top
View user's profile Send private message
tazinblack
Veteran
Veteran


Joined: 23 Jan 2005
Posts: 1146
Location: Baden / Germany

PostPosted: Sat Jul 19, 2008 7:38 am    Post subject: Reply with quote

Aha, so langsam verbreiten sich die Dinger doch etwas.

Ähm ich hab diverse von den Typen FAS270, FAS270c, FAS2020, FAS2020c, FAS2050c und hoffentlich bald ne FAS3020c oder ne 31irgendwas wie die neue jetzt heißt, die da grad rauskommt.

Überlegst Du noch oder hast Du schon eine?
_________________
Gruß / Regards
tazinblack
_______________________________________________________
what's the point in being grown up if you can't be childish sometimes
Back to top
View user's profile Send private message
Evildad
Guru
Guru


Joined: 15 Apr 2004
Posts: 475

PostPosted: Sat Jul 19, 2008 7:55 am    Post subject: Reply with quote

Haben bei uns die FAS3020c aber auch schon diverse alte Serien... immer nur den Kopf ausgetauscht da laufen noch 8GB Platten
Ja irgendwie kommt man sich da als Sonderling vor :-)

NetApp was ? :lol:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum