• DOS batch file woes

    From Spectre@21:3/101 to Adept on Monday, February 03, 2020 17:15:00
    I remember elsewhere there being a discussion on batch files and "if errorlevel 1" meaning "if errorlevel >= 1" (or <=1) rather than
    strictly equal, so if this is somehow a parallel execution sort of
    thing, maybe there's multiple threads doing unpredictable
    things because of it?

    ...admittedly, that last one is more than a bit of a stretch. I'm

    Fresh eyes, fresh mind... This script is running 8 times in parallel..


    If exist /bbs/test goto post (does test exist? If yes skip all the copying) echo > /bbs/test (well seeing as it didn't make one now)

    del /bbs/test (remove the lock file when we're done)
    :post
    goto loop

    They try and test for whether there is already a copy in progress if it isn't then create the "test" file because I'm here now. Generate the random errorlevel, yes it sets the NUM variable with each errorlevel until the errorlevel is equal to or greater than any test errorlevel. So at the end, only
    a single file gets copied once at a time, my first iteration of this whole idea copied every file multiple times until the errorlevel condition was breached. This was cleaner.

    Generally this lock method works, I use it in all my door batch files. So i'm not sure what the problem is here and now. Shrug...

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: < Scrawled in blood at The Lower Planes > (21:3/101)
  • From Spectre@21:3/101 to Anyone Else on Sunday, February 02, 2020 14:09:00
    Alrighty, so I have a section of script that copies a "random" ansi file into the goodbye.ans position as the logoff screen. Its called each time a user logs off oddly enough. Now, in theory to me, I can't see anything logically wrong with it, but somehow I'm ending up with partial copys of files being layered one over the other, so you can end up with a mash up of anywhere from 1-4 images... Heres whats in use at the moment...

    :afterbbs
    if exist \sbbs\test goto post
    echo > \sbbs\test

    rand 13
    if errorlevel 1 set NUM=1
    if errorlevel 2 set NUM=2
    if errorlevel 3 set NUM=3
    if errorlevel 4 set NUM=4
    if errorlevel 5 set NUM=5
    if errorlevel 6 set NUM=6
    if errorlevel 7 set NUM=7
    if errorlevel 8 set NUM=8
    if errorlevel 9 set NUM=9
    if errorlevel 10 set NUM=0
    if errorlevel 11 set NUM=A
    if errorlevel 12 set NUM=B
    if errorlevel 13 set NUM=C
    copy \goodbye\%NUM%.ans \sbbs\txt\goodbye.ans
    del \sbbs\test

    :post
    goto loop

    As I see it, somehow the script is not seeing the if exist properly and or somehow multiple copies are going on at once. Any thoughts on this lot?

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: < Scrawled in blood at The Lower Planes > (21:3/101)
  • From Spectre@21:3/101 to Anyone Else on Sunday, February 02, 2020 14:09:00
    Alrighty, so I have a section of script that copies a "random" ansi file into the goodbye.ans position as the logoff screen. Its called each time a user logs off oddly enough. Now, in theory to me, I can't see anything logically wrong with it, but somehow I'm ending up with partial copys of files being layered one over the other, so you can end up with a mash up of anywhere from 1-4 images... Heres whats in use at the moment...

    :afterbbs
    if exist \sbbs\test goto post
    echo > \sbbs\test

    rand 13
    if errorlevel 1 set NUM=1
    if errorlevel 2 set NUM=2
    if errorlevel 3 set NUM=3
    if errorlevel 4 set NUM=4
    if errorlevel 5 set NUM=5
    if errorlevel 6 set NUM=6
    if errorlevel 7 set NUM=7
    if errorlevel 8 set NUM=8
    if errorlevel 9 set NUM=9
    if errorlevel 10 set NUM=0
    if errorlevel 11 set NUM=A
    if errorlevel 12 set NUM=B
    if errorlevel 13 set NUM=C
    copy \goodbye\%NUM%.ans \sbbs\txt\goodbye.ans
    del \sbbs\test

    :post
    goto loop

    As I see it, somehow the script is not seeing the if exist properly and or somehow multiple copies are going on at once. Any thoughts on this lot?

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: < Scrawled in blood at The Lower Planes > (21:3/101)
  • From Spectre@21:3/101 to Adept on Monday, February 03, 2020 17:15:00
    I remember elsewhere there being a discussion on batch files and "if errorlevel 1" meaning "if errorlevel >= 1" (or <=1) rather than
    strictly equal, so if this is somehow a parallel execution sort of
    thing, maybe there's multiple threads doing unpredictable
    things because of it?

    ...admittedly, that last one is more than a bit of a stretch. I'm

    Fresh eyes, fresh mind... This script is running 8 times in parallel..


    If exist /bbs/test goto post (does test exist? If yes skip all the copying) echo > /bbs/test (well seeing as it didn't make one now)

    del /bbs/test (remove the lock file when we're done)
    :post
    goto loop

    They try and test for whether there is already a copy in progress if it isn't then create the "test" file because I'm here now. Generate the random errorlevel, yes it sets the NUM variable with each errorlevel until the errorlevel is equal to or greater than any test errorlevel. So at the end, only a single file gets copied once at a time, my first iteration of this whole idea copied every file multiple times until the errorlevel condition
    was breached. This was cleaner.

    Generally this lock method works, I use it in all my door batch files. So i'm not sure what the problem is here and now. Shrug...

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: < Scrawled in blood at The Lower Planes > (21:3/101)