Toon posts:

Variablen uit een text file halen DOS

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik ben bezig met een Script voor TSM waar bij ik bepaalde variablen uit een text file wil halen. En daar mee een process op wil starten mijn script ziet er als volgt uit.

dsmadmc.exe -id=Username -password=Password -tab "select process_num from processes where process = 'Backup Storage Pool' > temp.txt"

dsmadmc.exe -id=Username -password=Password "cancel pro < temp.txt"

Het probleem zit hem in het uitlezen van de waarde uit temp.txt

alleen:

dsmadmc.exe -id=Username -password=Password < temp.txt

werkt wel echter het dan mis ik het commando cancel pro

Temp.txt heeft een nummer als waarde, het commando zou dus b.v.b. zijn "cancel pro 001"

Ik hoop dat iemand mij hier bij kan helpen

  • wens
  • Registratie: Juni 2002
  • Laatst online: 21-05 18:19
lees temp.txt uit en stop deze in een variabele:

FOR /F "TOKENS=1* DELIMS=\" %%A IN ('ECHO temp.txt') DO SET NUMBER=%%A

en voer daarna je commando uit:

dsmadmc.exe -id=Username -password=Password "cancel pro %NUMBER%"

Verwijderd

Topicstarter
Wens ik heb de onderstaande regels toegevoegd aan het script alleen word de variabele nu temp.txt

FOR /F "TOKENS=1* DELIMS=\" %%A IN ('ECHO temp.txt') DO SET NUMBER=%%A

dsmadmc.exe -id=Username -password=Password "cancel pro %NUMBER%"

dus cancel process temp.txt

  • _Squatt_
  • Registratie: Oktober 2000
  • Niet online
Waarschijnlijk moet je 'ECHO temp.txt' vervangen door 'TYPE temp.txt'.

(of een ander commando om de inhoud van een file te laten zien, in DOS was dat altijd 'type').

"He took a duck in the face at two hundred and fifty knots."


Verwijderd

Topicstarter
Ok ben er uit Wens heb de ECHO verwijderd script ziet er nu zo uit

FOR /F "TOKENS=1* DELIMS=\" %%A IN (temp.txt) DO SET NUMBER=%%A
dsmadmc.exe -id=Username -password=Password "cancel pro %NUMBER%"

mijn dank is groot _/-\o_