RCG needs help with possible poison characters (getting clos

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: RCG needs help with possible poison characters (getting

#16 Post by Ed Dyreen » 09 Nov 2012 15:17

timbertuck wrote:would appreciate it someone could set me on the right track. anyone???
Hi timbertuck :)

Which Operating System you are running this batch on ?
Are you running a debugger ?

Remove all functions that work and only post the part u are having problems with.
Start removing all 'REM' and 'ECHO' statements.
People may be more willing to help if you can trim it down a bit !

Don't forget to post the output you are getting and how it differs from what you expect.

Regards,
ed

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: RCG needs help with possible poison characters (getting

#17 Post by timbertuck » 12 Nov 2012 09:59

Ed Dyreen wrote:
timbertuck wrote:would appreciate it someone could set me on the right track. anyone???
Hi timbertuck :)
Which Operating System you are running this batch on ?
Are you running a debugger ?
Remove all functions that work and only post the part u are having problems with.
Start removing all 'REM' and 'ECHO' statements.
People may be more willing to help if you can trim it down a bit !
Don't forget to post the output you are getting and how it differs from what you expect.
Regards,
ed


Hey Ed! Many Thanks for responding :mrgreen:

running on win 7 64 bit, no to debugger (recommendations?)

so i have tried several attempts to trim it down and all i did was make it different somehow (as output was diff)
but i tried again to do it and found some error's in my code which i fixed but still have a nagging issue.
the output should be a 64 bit string times 4. but it rarely gets to the 64th character and i don't know why.

here is the output from the command though it is not spaced correctly in this post.

Code: Select all

           01234567890123456789012345678901234567890123456789012345678901234
randval is ~|{|)_|\?:~@?[;},#-,@\^$##`}]{|/,.~[,@)^@;@[/^+<^@#<_*)?:|`:$~)]
randval is *( < )\[_^' \\#;[\| ,;..:*)>\@-[=.`>\(>&,:{.-#|.&>\?/&* <#+*
randval is  +?`)@<[* +.+@[?[&,;'_/)'<**@=.,+}[]@>+:$;<=$#|=&;)(`;/|/`\
randval is |&&._^ }*.[ +^/;>#(*>/^=}'{,]*(],@\'=[/$&<@]:/\ =/ ++>(#<}-^
randval is ;&>`)$-,^\~/=-'}'|~((&^&~,`{_</=.#;@{(;,,',|#<:`~^>@&@ ./


and here is the trimmed down command as best i could do.

Code: Select all

@echo off
echo.
echo            01234567890123456789012345678901234567890123456789012345678901234
setlocal enableextensions enabledelayedexpansion
set charset=S
set "s=^~`@#$&:;_/.,-+=\|][{}'?()@*<> !%^^"
set count=& set count2=
REM set /a eval7=%random% %% 33

:newloop
set /a count2+=1
      :doloop
      set /a count+=1
         if /i "%CharSet%"=="S" (set /a eval7=%random% %% 33) & (set randval=!s:~%eval7%,1!) & set "randval_!count!=!randval!"
      set newval=!newval!!randval_%count%!
      if !count! GTR 64 goto display
      goto :doloop

      :display
echo randval is !newval!
if !count2! GTR 4 goto end
set newval=
set count=
goto :newloop

:end
endlocal


so it runs, it emits, but just not to 64 characters consistently.

hopefully i did this right :)

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: RCG needs help with possible poison characters (getting

#18 Post by Ed Dyreen » 12 Nov 2012 10:27

'
Looks a lot better already :)

I'll have closer look tomorrow if no-one helps you out( it's been a loong day ) :wink:

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: RCG needs help with possible poison characters (getting

#19 Post by timbertuck » 12 Nov 2012 13:48

Ed Dyreen wrote:'
Looks a lot better already :)
I'll have closer look tomorrow if no-one helps you out( it's been a loong day ) :wink:


thanks Ed, no worries. but appreciate any help you can give. im getting very close to having it work completely. now that i got the extended set working, its just the special one that is the problem.

in the orig program, i had it spit out (4) 16 char's string, in the new one above, i ramped it up to (64) to see if it would break, but it didnt. so you can bring the 64 back to 16 to keep it inline with RAND7.bas

im sure that part of the issue is using the following char's: Space, DoubleQuote, Caret, Percent, Exclamation in the special set, but want to use all possible characters (33), though i think that the DoubleQuote will be the problem char that cant be resolved.

TT

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: RCG needs help with possible poison characters (getting

#20 Post by Ed Dyreen » 13 Nov 2012 11:46

'
You want to spit out a random line from a set of fixed-lines or a line build up with random characters ?
And the line needs to be always a specific length or a random length ?

Code: Select all

@echo off &setlocal enableextensions enabledelayedexpansion
::
:main ()
:: (
       set "$charSet=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
       set "$charSet"
       ::
       for /l %%? in (

              1, 1, 4

       ) do (
              set "$string=" &for /l %%? in (

                     1, 1, 64

              ) do (
                     set /a $random = !random! %% 33 &for %%? in (

                            !$random!

                     ) do   set "$char=!$charSet:~%%?,1!"
                     ::
                     set "$string=!$string!!$char!"
              )
              ::
              set "$string[%%?]=!$string!"
              set "$string[%%?]"
       )
:: )
pause &endlocal &exit /b

Code: Select all

$charSet=^~`@#$&:;_/.,-+=\|][{}'?()@*<> !%"
$string[1]=[]&^&>[~`'`]|@=.*(,--|@(+/|!@}'>^~*|\%*=__./|~(;;;@>? )^|~-_?_)%
$string[2]=@ ~@!.**${..*:%,^?:=; &^@\@^$^/=&/)_->:|'<}!=)`&~?:?{&*,_)=#)#[]
$string[3]=);${#*.}!$:@^$():('/>(![`~=)==?;;{@}^!+<%[$\].=<|#}$}<}}[;,:|~]~
$string[4]=`/+_,_,{!%!!@}] !&[.~=(; :   -*/@%`?&,%  :.:>(~~|#$%@? *;<>\~\!>
Druk op een toets om door te gaan. . .
The matrix could be of interest to you

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: RCG needs help with possible poison characters (getting

#21 Post by timbertuck » 13 Nov 2012 13:40

Ed Dyreen wrote:'
You want to spit out a random line from a set of fixed-lines or a line build up with random characters ?
And the line needs to be always a specific length or a random length ?

Code: Select all

@echo off &setlocal enableextensions enabledelayedexpansion
::
:main ()
:: (
       set "$charSet=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
       set "$charSet"
       ::
       for /l %%? in (

              1, 1, 4

       ) do (
              set "$string=" &for /l %%? in (

                     1, 1, 64

              ) do (
                     set /a $random = !random! %% 33 &for %%? in (

                            !$random!

                     ) do   set "$char=!$charSet:~%%?,1!"
                     ::
                     set "$string=!$string!!$char!"
              )
              ::
              set "$string[%%?]=!$string!"
              set "$string[%%?]"
       )
:: )
pause &endlocal &exit /b

Code: Select all

$charSet=^~`@#$&:;_/.,-+=\|][{}'?()@*<> !%"
$string[1]=[]&^&>[~`'`]|@=.*(,--|@(+/|!@}'>^~*|\%*=__./|~(;;;@>? )^|~-_?_)%
$string[2]=@ ~@!.**${..*:%,^?:=; &^@\@^$^/=&/)_->:|'<}!=)`&~?:?{&*,_)=#)#[]
$string[3]=);${#*.}!$:@^$():('/>(![`~=)==?;;{@}^!+<%[$\].=<|#}$}<}}[;,:|~]~
$string[4]=`/+_,_,{!%!!@}] !&[.~=(; :   -*/@%`?&,%  :.:>(~~|#$%@? *;<>\~\!>
Druk op een toets om door te gaan. . .
The matrix could be of interest to you


Thanks Ed! You Solved my riddle of the charset... now the mini program in the previous post works as expected. of course now the original RAND7.bas is not preserving spaces but i will tackle that later today. as long as the mini program worked, i can fix that issue (i think) without supervision :)

Note for anyone wanting to use the full keyboard set, it is all about placement, first the double caret's, then the reg chars skipping exclamation ! and percent %, then add SPACE, caret BANG, double percent %% and then double quote, caret and double quote. that opens up the full keyboard for random characters. i think i won't play with the other exotic chars as they are not standard and few programs would accept them.
so the full line is: set "s=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"

now back to your solution Ed, i have a few questions.
like what does this line do? i am unfamiliar with that syntax. i get the exclamation on the outside, but after the colon, i dont know how it gets the char position from :~%%?
set "$char=!$charSet:~%%?,1!"

and this line, what is it doing? im really just not understanding the %%? part, i understand what set does and the delayed expansion as well.
set "$string[%%?]=!$string!"

and shouldn't the random 33 be actually 34 (as there are 33 special char's including the space) oops never mind my error :mrgreen:

thanks again for all you help.
oh btw, i see this alot and was wondering if you could translate it? :roll:
Druk op een toets om door te gaan. . .

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: RCG needs help with possible poison characters (getting

#22 Post by timbertuck » 13 Nov 2012 14:45



in reference to this post, i had two questions about:

'$' cannot be used to strip quotes from metavariables.

';' as a variable name cannot be displayed by using the set command, only by echo.

not familiar with using $, can you elaborate a little or point me to a post or two?

so using ; in front of a varname effectively hides it from set??? very interested in that functionality so again please point me in the right direction..


note on posting this question here, thought that it didnt warrant a main topic question, let me know if i was wrong..i know that your the right syntax guy though :P

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: RCG needs help with possible poison characters (getting

#23 Post by Ed Dyreen » 13 Nov 2012 15:16

timbertuck wrote:in reference to this post, i had two questions about:

'$' cannot be used to strip quotes from metavariables.
Some strip double quotes from strings this way

Code: Select all

for %%? in ( "removeQuotes" ) do echo.%%~?
but %%~$ won't work

Code: Select all

for %%$ in ( "removeQuotes" ) do echo.%%~$
As it is part of for's special expansion phase.

Code: Select all

for /?

 %~I

 %~fI
 %~dI
 %~pI
 %~nI
 %~xI
 %~sI
 %~aI
 %~tI
 %~zI
 %~$PATH:I
timbertuck wrote:';' as a variable name cannot be displayed by using the set command, only by echo.

not familiar with using $, can you elaborate a little or point me to a post or two?

Code: Select all

set ";hideVar=hidden from set"
set ";hideVar"
set ""
This behavior is totally new for me aswell, I call it hidevar, as it fails to print here for some reason, there are a few more of those like the readOnly var %=c:% etcetera...
timbertuck wrote:oh btw, i see this alot and was wondering if you could translate it? :roll:
Druk op een toets om door te gaan. . .
Drücken Sie eine beliebige Taste, um fortzufahren. . .

ed

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: RCG needs help with possible poison characters (getting

#24 Post by timbertuck » 13 Nov 2012 15:34

Ed Dyreen wrote:

Code: Select all

set ";hideVar=hidden from set"
set ";hideVar"
set ""
This behavior is totally new for me aswell, I call it hidevar, as it fails to print here for some reason, there are a few more of those like the readOnly var %=c:% etcetera...
Druk op een toets om door te gaan. . .
bedeutet
Drücken Sie eine beliebige Taste, um fortzufahren. . . :lol:


ok, got it. got all questions answered but one or two :lol:
why the brackets in the following line?
set "$string[%%?]=!$string!"

and yes, very funny :mrgreen: i get the translation, should have just used translate.google.com (which i did, too easy)
cant find the "any" key though :o might need some help there 8)

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: RCG needs help with possible poison characters (getting

#25 Post by Ed Dyreen » 13 Nov 2012 15:42

timbertuck wrote:ok, got it. got all questions answered but one or two :lol:
why the brackets in the following line?
set "$string[%%?]=!$string!"
Aacini recently proposed we use array[index] notation, it make the code closer to HLL's notation and easier to follow.
timbertuck wrote:cant find the "any" key though :o might need some help there 8)
That one easy, close your eyes and your finger down :)

Auf wiedersehen,
ed

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: RCG needs help with possible poison characters (getting

#26 Post by timbertuck » 14 Nov 2012 08:41

well, in doing some range testing, i found out that the simplified program does not emit the doublequotes " in the selection set. i trimmed it down a little bit more so it is more concise. i did the same for your program but yours does not do the doublequote " either. so i will post both codes. so my question is how to get the doublequote to emit properly.

trRand.bas

Code: Select all

@echo off & setlocal enableextensions enabledelayedexpansion
set charset=S
set "s=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
echo "%s:~30,1%"
set count=& set count2=
:newloop
set /a count2+=1
:doloop
   set /a count+=1
   if /i "%CharSet%"=="S" (set /a eval7=%random% %% 33) & (set "randval=!s:~%eval7%,1!") & set "randval_!count!=!randval!")
   set "newval=!newval!!randval_%count%!"
   if !count! GTR 64 goto display
goto :doloop
:display
   echo randval is !newval!
   if !count2! GTR 40 goto end
   set newval=&set count=
goto :newloop
:end
endlocal


yourRand.bas

Code: Select all

@echo off &setlocal enableextensions enabledelayedexpansion
:main ()
       set "$charSet=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
       set "$charSet"
    for /l %%? in (1, 1, 20) do (
      set "$string=" &for /l %%? in (1, 1, 64) do (
          set /a $random = !random! %% 33 &for %%? in (!$random!) do set "$char=!$charSet:~%%?,1!"
          set "$string=!$string!!$char!"
      )
     if %%? LSS 10 set "$string[%%?]  = !$string!"
     if %%? GEQ 10 set "$string[%%?] = !$string!"
     set "$string[%%?]"
   )
pause &endlocal &exit /b


edit: Yours is way faster than my code, so i will implement it once the " is fixed. Thanks Ed!
edit: i ran a 95 char string 40 times and yours was .78 seconds, mine was a crazy 7.9 seconds, yours is 800% faster!!!
Last edited by timbertuck on 14 Nov 2012 08:53, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: RCG needs help with possible poison characters (getting

#27 Post by foxidrive » 14 Nov 2012 08:49

You are putting poison characters in your character selection - can your code handle them when it comes to using the character selections?

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: RCG needs help with possible poison characters (getting

#28 Post by timbertuck » 14 Nov 2012 08:55

foxidrive wrote:You are putting poison characters in your character selection - can your code handle them when it comes to using the character selections?


hey foxi..

yup putting them in the set is on purpose. im trying to get to 95 characters in the selection set, and the only char that doesn't emit is the " (doublequote). so the problem is in my code somewhere, i just dont know where.

thanks

TT

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: RCG needs help with possible poison characters (getting

#29 Post by foxidrive » 14 Nov 2012 09:01

But if you get that sorted, will you then have a problem with the batch file that manipulates the poison characters?

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: RCG needs help with possible poison characters (getting

#30 Post by timbertuck » 14 Nov 2012 09:19

foxidrive wrote:But if you get that sorted, will you then have a problem with the batch file that manipulates the poison characters?


all the batch file is doing is emitting a string of random characters, it doesn't act on the result, just reports it. so all i need to do is make sure that every char is emitting properly and in doing some range testings, the only char that does not make it in the string is the double quote. so maybe it is how the S char set is assembled?? maybe move the Caret Doublequote inside the other double quote??

thoughts?

Post Reply