- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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...
Admin
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
Admin
You misspelled "sixty"...
Admin
I believe that code is actually unholy.
Admin
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.
Admin
<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>
Admin
Damn. I'd almost think that was directed at me... [:$]
Admin
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.
Admin
[:S] OMG. Run for the hills, leap into the nearest ditch, the batch file from hell is comming!!! [:P]
Admin
Batch files? We don't need no stinkin' batch files!
Admin
I can't get it to compile! ;-)
Admin
Cute. Have they not discovered make yet?
Admin
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.
Admin
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!
Admin
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.
Admin
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?
Admin
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.
Admin
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 ...
Admin
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.
Admin
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.
Admin
Who recommends against scripts?
Admin
>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.
Admin
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.
Admin
Well, at least it is cheaper than using SMS
Admin
I for one recommend against 65 of them. There comes a time when scripts become overwhelming and a new tool is needed.
Admin
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.
Admin
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.
Admin
Laugh at me all you want. But why exactly did you have to call me a fool?
Admin
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.
Admin
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!
Admin
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.
Admin
[:|]
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.
Admin
echo. | date > tmp
Admin
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?
Admin
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.
Admin
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...)