Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

DOS: Zeilenzahl in Variable holen

Empfohlene Antworten

Veröffentlicht

Hallo

Ich würde gern die Anzahl von Zeilen einer Datei in einer Variable einlesen (unter DOS, nicht in eienr DOS-Box).

Eine Datei sieht beispielweise so aus (ist eine Ausgabe von "gdisk /status"):

disk partitions cylinders ...

1 3 555

2 4 777

Wenn die Datei 2 Zeilen hat, möchte ich Befehl A ausführen.

Wenn die Datei 3 Zeilen hat, möchte ich Befehl B ausführen.

Wie geht das?

@echo on

@gdisk2 /status >gd.ak1

@

find /n/v "dummystring" gd.ak1 | find "[5]" >nul

if not errorlevel 1 goto platten4

@

find /n/v "dummystring" gd.ak1 | find "[4]" >nul

if not errorlevel 1 goto platten3

@

find /n/v "dummystring" gd.ak1 | find "[3]" >nul

if not errorlevel 1 goto platten2

@

find /n/v "No fixed disks" gd.ak1 | find "[2]" >nul

if not errorlevel 1 goto platte1

@

find /n/v "dummystring" gd.ak1 | find "[1]" >nul

if not errorlevel 1 goto platte0

@

echo fehler in programmlogik

goto ende

@

:platten4

@echo vier platten!

@goto ende


:platten3

@echo drei platten!

@goto ende


:platten2

@echo zwei platten!

@goto ende


:platte1

@echo eine platte!

@goto ende


:platte0

@echo null platten!

@goto ende


:ende 

@echo ---fertig---

ja, durch /n kommen die Nummern

@echo on

@gdisk2 /status >gd.ak1

@

find /n/v "dummystring" gd.ak1 | find "[5]" >nul

if not errorlevel 1 goto platten4

@

find /n/v "dummystring" gd.ak1 | find "[4]" >nul

if not errorlevel 1 goto platten3

@

find /n/v "dummystring" gd.ak1 | find "[3]" >nul

if not errorlevel 1 goto platten2

@

find /n/v "No fixed disks" gd.ak1 | find "[2]" >nul

if not errorlevel 1 goto platte1

@

find /n/v "dummystring" gd.ak1 | find "[1]" >nul

if not errorlevel 1 goto platte0

@

echo fehler in programmlogik

goto ende

@

:platten4

@echo vier platten!

@goto ende


:platten3

@echo drei platten!

@goto ende


:platten2

@echo zwei platten!

@goto ende


:platte1

@echo eine platte!

@goto ende


:platte0

@echo null platten!

@goto ende


:ende 

@echo ---fertig---

Moin,

in wie fern ist das die Lösung der Aufgabe? In welcher Variablen steht denn nun die Zahl?

Gruß

Reinhold

(mehrfacher Träger der "goldenen Axt" als Haarspalter des Monats

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.