d3luxe
Goto Top

Batch if abfrage ob variable eof ist

Also ich programmiere derzeit an einer batch die ein passwort generieren soll die basis ist die eingabe eines textes des users dieser text wird in hex umgewandelt... das funktioniert soweit! Das ergebnis soll in eine textdatei und das alles in eine zeile wie ich das mache hab ich herausgefunden.. nur will die abfrage von eof nicht so wie ich weswegen das ganze nicht machbar ist..


@echo off
set /p ta=Geben sie den speicherort an, an dem das passwort gespeichert werden soll:
echo Bei saetzen bitte keine leerzeichen sonder - verwenden.
set /p va=Geben sie den zu uebersetzenden text ein:
SET _startchar=0
SET _length=1
SET _donor=%va%
:loop
CALL SET _substring=%%_donor:~%_startchar%,%_length%%%
echo %_substring%
if %_substring%==- set %vb%=20
if %_substring%==a set %vb%=61
if %_substring%==b set %vb%=62
if %_substring%==c set %vb%=63
if %_substring%==d set %vb%=64
if %_substring%==e set %vb%=65
if %_substring%==f set %vb%=66
if %_substring%==g set %vb%=67
if %_substring%==h set %vb%=68
if %_substring%==i set %vb%=69
if %_substring%==j set %vb%=6A
if %_substring%==k set %vb%=6B
if %_substring%==l set %vb%=6C
if %_substring%==m set %vb%=6D
if %_substring%==n set %vb%=6E
if %_substring%==o set %vb%=6F
if %_substring%==p set %vb%=70
if %_substring%==q set %vb%=71
if %_substring%==r set %vb%=72
if %_substring%==s set %vb%=73
if %_substring%==t set %vb%=74
if %_substring%==u set %vb%=75
if %_substring%==v set %vb%=76
if %_substring%==w set %vb%=77
if %_substring%==x set %vb%=78
if %_substring%==y set %vb%=79
if %_substring%==z set %vb%=7A
if %_substring%==1 set %vb%=31
if %_substring%==2 set %vb%=32
if %_substring%==3 set %vb%=33
if %_substring%==4 set %vb%=34
if %_substring%==5 set %vb%=35
if %_substring%==6 set %vb%=36
if %_substring%==7 set %vb%=37
if %_substring%==8 set %vb%=38
if %_substring%==9 set %vb%=39
if %_substring%==0 set %vb%=30
set varText=%vb%
if /I %_startchar% GEQ 1 set varText=%varText%%vb%
SET /a _startchar=%_startchar%+1
if %_substring%==eol goto next
goto loop
:next
echo %varText% >> %ta%\passwort.txt
echo ende >> %ta%\passwort.txt


Nach dem die eingabe umgesetzt wurde endet es.. ohne eol genutzt zu haben kann mir wer sagen wieso?

Edit:
Denkt euch die % bei %vb% weg war en versehen ^^ wird gleich ersetzt :D

Content-Key: 108308

Url: https://administrator.de/contentid/108308

Printed on: April 24, 2024 at 08:04 o'clock

Member: bastla
bastla Feb 06, 2009 at 20:55:22 (UTC)
Goto Top
Hallo d3luxe und willkommen im Forum!

Vielleicht so
if "%_substring%"=="" goto next
oder so
if not defined _substring goto next
Grüße
bastla
Member: d3luxe
d3luxe Feb 06, 2009 at 21:11:57 (UTC)
Goto Top
Danke für deine Antwort bastla, leider geht das bei mir nicht.. ich werde jetzt das ganze bis zum fehler zurückverfolgen also sehr viel pause :D ich werd den beitrag gleich mit dem ergebnis editieren.

Edit:
Ok.. es endet bei den ganzen if abfragen wenn substring undefiniert is.. das heißt ich verschiebe jetzt ma das goto next und teste nochma ok :D
Member: bastla
bastla Feb 06, 2009 at 21:19:27 (UTC)
Goto Top
Hallo d3luxe!

Falls ich Dein Vorhaben richtig interpretiere, sollte es eher so klappen:
@echo off & setlocal
set /p ta=Geben sie den speicherort an, an dem das passwort gespeichert werden soll:
echo Bei saetzen bitte keine leerzeichen sonder - verwenden.
set /p va=Geben sie den zu uebersetzenden text ein:

SET /a _startchar=0
SET /a _length=1
SET "_donor=%va%"  
SET varText=

:Loop
CALL SET _substring=%%_donor:~%_startchar%,%_length%%%
if not defined _substring goto :Fertig

echo %_substring%
if %_substring%==- set "vb=20"  
if %_substring%==a set "vb=61"  
if %_substring%==b set "vb=62"  
if %_substring%==c set "vb=63"  
if %_substring%==d set "vb=64"  
if %_substring%==e set "vb=65"  
if %_substring%==f set "vb=66"  
if %_substring%==g set "vb=67"  
if %_substring%==h set "vb=68"  
if %_substring%==i set "vb=69"  
if %_substring%==j set "vb=6A"  
if %_substring%==k set "vb=6B"  
if %_substring%==l set "vb=6C"  
if %_substring%==m set "vb=6D"  
if %_substring%==n set "vb=6E"  
if %_substring%==o set "vb=6F"  
if %_substring%==p set "vb=70"  
if %_substring%==q set "vb=71"  
if %_substring%==r set "vb=72"  
if %_substring%==s set "vb=73"  
if %_substring%==t set "vb=74"  
if %_substring%==u set "vb=75"  
if %_substring%==v set "vb=76"  
if %_substring%==w set "vb=77"  
if %_substring%==x set "vb=78"  
if %_substring%==y set "vb=79"  
if %_substring%==z set "vb=7A"  
if %_substring%==1 set "vb=31"  
if %_substring%==2 set "vb=32"  
if %_substring%==3 set "vb=33"  
if %_substring%==4 set "vb=34"  
if %_substring%==5 set "vb=35"  
if %_substring%==6 set "vb=36"  
if %_substring%==7 set "vb=37"  
if %_substring%==8 set "vb=38"  
if %_substring%==9 set "vb=39"  
if %_substring%==0 set "vb=30"  

SET "varText=%varText%%vb%"  
SET /a _startchar+=1
goto :Loop

:Fertig
>>"%ta%\passwort.txt" echo %varText%  
>>"%ta%\passwort.txt" echo ende  
Grüße
bastla
Member: d3luxe
d3luxe Feb 06, 2009 at 21:29:21 (UTC)
Goto Top
Danke, es funktioniert :D Ich hab es sogar noch selbst gelöst ^^ aber ohne deine abfrage hätte ichs nicht geschafft.


Ich makiere den beitrag als gelöst