• diaphanein (unregistered)

    Personally, I love the "random" temp file names. There's nothing more meaningful that "~ADT606.tmp".  Now, if this was a generated file name, file.  But a hard-coded gibberish filename?  Must have been done on the day Peter was playing Tetris...

  • (cs) in reply to diaphanein

    I can't think of any witty comments about this WTF.  I just wanted to say, Alex, you continue to amaze me with your Titles...

    keep up the great work!

    -blue

  • Dave (unregistered)

    You misspelled "sixty"...

  • Aaron (unregistered)

    I believe that code is actually unholy.

  • D. Philippe (unregistered)

    This is really cool (in a hellish way).  What a nightmare to try to maintain, but at some base hackish level it's pretty cool.

    And for those of you who think this is rare, MS distrubtes a 3,000+ line batch file with Platform Builder for building WinCE OSes.

  • (cs)

    <FONT face=Arial size=1>That is unbelievably unbelievable! Some people sincerely believe in "Try, try again" to make things work. Even when using batch files. You gotto take your hat off to these brave folk (and, naturally, to the ones maintaining it).</FONT>

    <FONT face=Arial size=1>And yeah, great title! [:D]</FONT>

  • (cs)

    * For the Office Space [imdb.com] impaired, names change to protect the innocent


    Damn. I'd almost think that was directed at me... [:$]
  • Chip (unregistered)

    If I was introduced to the coder who wrote that system, first I would sincerely and deeply compliment them on their cleverness and skill, and then I would borrow their laptop and beat them senseless with it.

  • (cs)

    [:S] OMG.  Run for the hills, leap into the nearest ditch, the batch file from hell is comming!!! [:P]

  • Jose Cuervo (unregistered) in reply to cm5400

    Batch files?  We don't need no stinkin' batch files!

  • Adrian (unregistered)

    I can't get it to compile! ;-)

  • L (unregistered) in reply to D. Philippe
    Anonymous:

    And for those of you who think this is rare, MS distrubtes a 3,000+ line batch file with Platform Builder for building WinCE OSes.



    Cute. Have they not discovered make yet?
  • (cs)

    I thought I was clever using a batch file to auto-update programs I'd written at startup,
    But I should of just written the programs with batch files.

  • (cs) in reply to Sweets

    I remember when I made batch file programs so that I could directly startup my old PC games (XCom, Civilization 1, Master of Orion 1, Doom 2...) after the PC boots from DOS 6.0. The default setting then was that Windows 3.1 was immediately started, to imitate booting  from then just-released Windows 95.

    I was only 14 then but I clearly understood that batch files were for setting the sequence of a batch of executables with or without specific parameters. That code on top is crazy.

    And that's production code?

    WTFing CRAZY!

  • Blarg (unregistered) in reply to Jon Limjap

    I'm not sure I understand why it's crazy to use batch scripting now that the system is finally capable of doing MORE than just running a bunch of executables.

    Is a Unix admin crazy for writing scripts to do administrative tasks? No, he's not, and a Windows admin isn't crazy for doing the same, no matter how far removed it may seem from your uneducated home-use batch file programming. I wager you could learn a surprising amount from trying to understand the script above.

    There are a lot of WTF's above, but writing batch files (regardless of how suitable you may consider them) is not one of them.

  • (cs) in reply to Blarg
    Anonymous:
    I'm not sure I understand why it's crazy to use batch scripting now that the system is finally capable of doing MORE than just running a bunch of executables.

    Is a Unix admin crazy for writing scripts to do administrative tasks?


    At least, the *NIX shells are full-fledged programming languages, not just command prompts with half-assed macro capabilities. And they are still recommended against, in case you didn't know.

    Oh wait, you were sarcastic, right?

  • Mario (unregistered) in reply to Blarg

    Anonymous:
    I'm not sure I understand why it's crazy to use batch scripting now that the system is finally capable of doing MORE than just running a bunch of executables. Is a Unix admin crazy for writing scripts to do administrative tasks? No, he's not, and a Windows admin isn't crazy for doing the same, no matter how far removed it may seem from your uneducated home-use batch file programming. I wager you could learn a surprising amount from trying to understand the script above. There are a lot of WTF's above, but writing batch files (regardless of how suitable you may consider them) is not one of them.

    If it were VBS or JS scripts, I'ld think this way too, but these are batch files. I expect Unix admins to use scripting languages instead of macro languages.

  • Purplet (unregistered) in reply to felix

    At least, the *NIX shells are full-fledged programming languages, not just command prompts with half-assed macro capabilities. And they are still recommended against, in case you didn't know.

    So yes, all the world is working to replace configure.sh ...


  • (withheld) (unregistered) in reply to Purplet

    Heh. I work for an ISP-slash-hosting-company-slash-you-name-it and one of the things we do is maintain a website for the use of employees belonging (yes 'belonging' in the proprietary sense) to a certain excessively large and breathtakingly evil financial institution which shall remain nameless.

    The site accepts some information and transfers it from the server where the site lives to another server which belongs to a financial services group, who then use the information to do whatever the hell it is they do with it.

    How is this conduit implemented?

    With batch files, of course! (And the natural place to put them is of course c:\WINNT\system32.)

    The amusing part is that Cygwin is actually installed (sorta, anyway), so this could've been done with a shell script, or even gasp with Perl -- but that's far more than I would expect from some of the people who've gone before me in the place where I'm working now. Besides, I've seen the Perl they wrote -- I'm in the middle of debugging a particularly egregious example, in fact, and it's just about enough to make me want to call in sick...hey, maybe I should submit a few of the choicest (ripest) bits.

  • (cs) in reply to Blarg

    There's nothing wrong with scripts/bat files.  The problem is that the NT shell sucks and finding information on the different commands is difficult.  I've got a book on all the commands but I still find somethings that are trivial in Unix are almost impossible in Windows.

  • (cs) in reply to felix

    felix:

    At least, the *NIX shells are full-fledged programming languages, not just command prompts with half-assed macro capabilities. And they are still recommended against, in case you didn't know.

    Who recommends against scripts?

  • (cs) in reply to Blarg

    >Is a Unix admin crazy for writing scripts to do administrative tasks?

    I'm going to take the bet that you're bluffing at least a bit on this, but the fact is that, yes, the guy's crazy. He must be brilliant because <FONT color=#000000>batch</FONT> doesn't even have a debugger, but crazy never the less.

    <FONT style="BACKGROUND-COLOR: #0000ff" color=#ffffff>He's crazy in the same manner that me digging ditches for a living using a teaspoon is crazy- there are -far- better ways to do this kind of thing.</FONT>

    If he wanted to script, then fine, use a half-decent scripting language.

    Or since I was 14, TurboC had the Command(..) function to call a DOS command and I knew how to use it.

    This is the kind of situation where the new boss (me, for example) walks in and says "wtf??" followed by "who wrote this?" and then finally, "why?" and then we start on how much I need to reduce staff.

  • (cs)

    Prelude: No, I'm not being sarcastic.  No, I'm not an idiot (much).

    Body: Back in the day (circa 1990) there was a lot being done with batch files and they could do some pretty wild stuff for such a simple environment.  There was a certain beauty in being able to get the machine to conform to your will and the guys who were the real cognoscenti, hell they walked on water.

    Finale: 'Course that was then and this is now....but WTF.

  • Top Cod3r (unregistered)

    Well, at least it is cheaper than using SMS

  • Tris Orendorff (unregistered) in reply to dubwai
    dubwai:

    Who recommends against scripts?


    I for one recommend against 65 of them.  There comes a time when  scripts become overwhelming and a new tool is needed.
  • Blarg (unregistered) in reply to memorex
    I'm going to take the bet that you're bluffing at least a bit on this

    No, I wasn't bluffing at all. Problem is, people are misunderstanding me, thinking I'm defending THIS usage. I'm not defending the use of batch files to implement this particular task, and as I said, there are plenty of WTFs in there. I'm defending writing batch files in cases where you want to do more than just run one executable after another. BAT scripting has come a long way since the days of MS-DOS, and to ignore it is as stupid as writing your own C program to handle something sed or awk could do.

    Windows scripting is still an optional install, as is any other scripting language you could think of. BAT processing is guaranteed to be available on any machine, and that makes it valuable in some circumstances. As for the fool who claims scripting is not recommended - ha! I laugh at you.

  • (cs) in reply to Purplet
    Anonymous:
    So yes, all the world is working to replace configure.sh ...

    If you're talking about the "standard" (as in, most common) configuration script, that one is automatically generated, not written by hand. It's thus object code, and its readability (or lack thereof) isn't much of an issue.

    I will, however, buy that there are situations where a batch file under Windows is the easiest and most convenient way to do something simple. Heck, I'm not a big shell script fan myself, and would never use one for a major application, but I confess to having a few hundred lines of shell code in the system I'm currently building.
  • (cs) in reply to Blarg
    Anonymous:
    As for the fool who claims scripting is not recommended - ha! I laugh at you.


    Laugh at me all you want. But why exactly did you have to call me a fool?

  • fatgeekuk (unregistered)

    Whats wrong with BATCH... you can do some really nice things with it.

     

    Ok, heres a task...

     

    write a batch file which will once executed create an environment variable that contains the name of the day of the week (Mon, Tue etc)

     

    The command file must use only intrinsic commands.

  • A. Nonymous (unregistered)

    I wrote a ~150 line database client in GNU Bash, but, I must confess, that my puny little deed, accomplished by resorting to dirty tricks like "exec" file descriptor redirection, spawning of a background "psql" process, arithmetic expansions and somesuch post-DOS black magic, pales in comparison to this magnificient feat.

    All hail Cesar, god of programming!

  • (cs) in reply to fatgeekuk
    Anonymous:

    a batch file which will once executed create an environment variable that contains the name of the day of the week (Mon, Tue etc)

    First, you need a file which just contains a new-line char, which we'll call NL.TXT

    Then you need a batch file, call THE.BAT, which is just:

    <FONT face="Courier New">Set Day = %4</FONT>

    Then you write a batch which contains:

    <FONT face="Courier New">date < NL.TXT > temp.bat
    call temp
    del temp.bat</FONT>

    Run that batch file. 

    It will run the DOS date command which will output the following into TEMP.BAT:

    <FONT face="Courier New">The current date is: Mon 04/11/2005
    Enter the new date: (mm-dd-yy)</FONT>

    we then run that as a batch file, so DOS runs the batch file called "The", with "<FONT face="Courier New">current date is: Mon 04/11/2005" </FONT><FONT face="Times New Roman">as it's command-line parameters.  That batch take the 4th ("Mon") and sets the evar.   Since we've called a batch file (THE) inside a batch file (TEMP) without using "call", we exit TEMP, and return to the original batch file (where we did use CALL), and delete temp.bat.</FONT>

    The NL.txt responds to the "Enter the new day" line.  IF you don't have such a file handy, you can skip references to it, but you'll have to hit enter an extra time when you run the batch file.

     

     

  • (cs) in reply to JamesCurran

    [:|]

    Um WTF?!

    Just

    set DayOfWeek=%DATE:~0,3%

    The limitation that both of ours suffer from, and can't be worked around AFAIK up through Windows Server 2003, is that the date command and %DATE% change their formatting depending on locale, so This will work whenever the machine is set to a locale where the three character day is listed first, for other locales, you'll have to change the substring. There may even be locales that don't have the day, I don't know.

  • Somebody (unregistered) in reply to JamesCurran
    JamesCurran:

    <font face="Courier New">date < NL.TXT > temp.bat
    </font>



    echo. | date > tmp
  • Me (unregistered) in reply to Somebody

    Better yet,

    date /t

    If you have the "DOS extensions" enabled (so I guess it wouldn't work on Win95?). You can also redirect it with pipes.

    Best abuse of batch files ever was a batch file to scan a folder for smilies and then update a configuration file with them, their names (sans extension) and even the -smiley shortcuts-. Then I realized that smilies added that way weren't visible on other people's machines. smacks forehead

    What is it with Linux fanboys always talking about "mastering the pipes commands" and that Windows losers don't have "that kind of control". (They do.) Even one of my teachers in college had the same opinion! "Use Linux because it has pipes and redirection!" WTF?

  • Mike (unregistered)

    This would be exhibit A for "goto considered harmful" if it was written in, you know, a language, but I guess there's not much choice when life is a batch.

  • IByte (unregistered)

    Hey, that looks a bit like the logon batch script at my dad's work. It includes things like forcibly killing explorer.exe (that's the Windows GUI; apparently they're trying to force an update of something) and checking network connectivity by checking for the existence of UNC paths (well, that's... er, "special").

    Note that system administration in that place is actually outsourced (which leads to OS updates on the managed machines being about three years out of date...)

Leave a comment on “Lifes A Batch. Then You Maintain One.”

Log In or post as a guest

Replying to comment #:

« Return to Article