Comment On Lifes A Batch. Then You Maintain One.

Immagine how exciting it must have been for Peter "batchwizard" Gibbons* to take over development and support for his company's "software distribution, configuration management, and auditing" system. Afterall, it would seem to be an excellent opportunity to learn more about Microsoft SMS, and how it's used and expanded upon in a large organization. Now, just try immagine how quickly excitement turned into dissapointment when Peter learned that the entire system was developed in Windows batch code. In over sixty-five command files. [expand full text]
« PrevPage 1Next »

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 12:13 • by diaphanein
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...

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 13:46 • by Blue
32402 in reply to 32399
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



Re: Lifes A Batch. Then You Maintain One.

2005-04-07 13:56 • by Dave
You misspelled "sixty"...

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 13:58 • by Aaron
I believe that code is actually unholy.

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 14:23 • by D. Philippe

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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 14:38 • by Tallies

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).


And yeah, great title! [:D]

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 14:45 • by Mike R


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





Damn. I'd almost think that was directed at me... [:$]

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 14:46 • by Chip
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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 15:25 • by cm5400
[:S] OMG.  Run for the hills, leap into the nearest ditch, the batch file from hell is comming!!! [:P]

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 16:17 • by Jose Cuervo
32417 in reply to 32414
Batch files?  We don't need no stinkin' batch files!

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 16:20 • by Adrian
I can't get it to compile! ;-)

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 16:54 • by L
32419 in reply to 32410
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?

Re: Lifes A Batch. Then You Maintain One.

2005-04-07 17:15 • by Sweets
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.



Re: Lifes A Batch. Then You Maintain One.

2005-04-07 20:41 • by Jon Limjap
32427 in reply to 32422
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!

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 00:34 • by Blarg
32431 in reply to 32427
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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 02:49 • by felix
32432 in reply to 32431
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?



Re: Lifes A Batch. Then You Maintain One.

2005-04-08 03:47 • by Mario
32434 in reply to 32431

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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 04:40 • by Purplet
32436 in reply to 32432
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 ...





Re: Lifes A Batch. Then You Maintain One.

2005-04-08 07:42 • by (withheld)
32438 in reply to 32436
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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 10:12 • by dubwai
32440 in reply to 32431

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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 10:13 • by dubwai
32441 in reply to 32432

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?

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 10:22 • by memorex
32442 in reply to 32431

>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 batch doesn't even have a debugger, but crazy never the less.


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.


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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 11:37 • by Bustaz Kool

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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 13:01 • by Top Cod3r
Well, at least it is cheaper than using SMS

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 18:43 • by Tris Orendorff
32492 in reply to 32441
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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-08 18:52 • by Blarg
32493 in reply to 32442
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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-11 00:03 • by cjs
32514 in reply to 32436
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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-11 02:27 • by felix
32515 in reply to 32493
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?



Re: Lifes A Batch. Then You Maintain One.

2005-04-11 06:35 • by fatgeekuk

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.

Hail to the King of Scripting!

2005-04-11 14:22 • by A. Nonymous
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!

Re: Lifes A Batch. Then You Maintain One.

2005-04-11 16:16 • by JamesCurran
32569 in reply to 32521
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:


Set Day = %4


Then you write a batch which contains:


date < NL.TXT > temp.bat
call temp
del temp.bat


Run that batch file. 


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


The current date is: Mon 04/11/2005
Enter the new date: (mm-dd-yy)


we then run that as a batch file, so DOS runs the batch file called "The", with "current date is: Mon 04/11/2005" 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.


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.


 


 

Re: Lifes A Batch. Then You Maintain One.

2005-04-11 19:52 • by Jeremy Morton
32582 in reply to 32569

[:|]


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.

Re: Lifes A Batch. Then You Maintain One.

2005-04-15 03:34 • by Somebody
32839 in reply to 32569
JamesCurran:


date < NL.TXT > temp.bat





echo. | date > tmp

Re: Lifes A Batch. Then You Maintain One.

2009-02-06 17:54 • by Me (unregistered)
242792 in reply to 32839
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?

Re: Lifes A Batch. Then You Maintain One.

2009-02-06 19:08 • by 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.

Re: Lifes A Batch. Then You Maintain One.

2009-02-08 07:25 • by 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...)

Re: Lifes A Batch. Then You Maintain One.

2009-05-18 04:20 • by wow gold (unregistered)
Out of runes of magic gold? Need it in urgent? Yes, I can understand you. As the most important currency, without rom gold, you ever can’t do anything. So you need to buy rom gold from those most professional and loyal game online shops with years’ experience and have a good reputation among players. Is there any difficult? No, when you need the rom gold, please feel free to contact us, we are promising to offer you the cheap runes of magic gold with fastest delivery. Moreover, we are online 24/7, you can contact us any time with any question about. So why are you still irresolute? Come here to grab your cheap runes of magic gold now. Crazy about running warhammer gold? Yup, it is so crucial indeed for us in Warhammer Online. Without it, we can even do nothing, without money to buy items, weapons and so on. So enough warhammer gold is substantial.
« PrevPage 1Next »

Add Comment