Reader 2 Reader

I once interviewed with a local tech company for the position of system administrator. The company used all Microsoft products, which was fine, since I was in my Windows NT fanboy stage at the time. During the interview, they told me that they were having a problem getting their backups to finish, because people were leaving files hanging open. I figured there was a way to fix this, so I did a little fooling around when I got home, worked up a hack to fix the problem, and sent that to them gratis. Of course I got offered the job, but I turned it down because I already had a good thing going, and they couldn’t really offer more. Turns out that the guy they wound up hiring came to work at my company about a year later because the company folded, so I think that was the right move…

Anyway, I sent in my hack to Windows Magazine, and it got printed. Even though I’m “all Linux all the time” now, I’m putting it here for historical reasons. (My original submission was heavily edited, and I think it wound up sounding a bit silly in a couple spots.)

Reader to Reader – December 1997

This passion came in handy recently. An administrator was making rounds at midnight to reboot machines so that a backup could catch files that were still open. I was helping close files after hours, and I came up with an idea: A scheduled batch file could automatically close open files. Much to the administrator’s surprise (this person had a UNIX background), I put the following command in a batch file:

for /f "skip=4 eol=T" %%i in ('net file') do net file %%i /close

The /f option parses output, and for this example, passes the first white-spaced token on to the rest of the line. (Other tokens can pass.) The eol=T keeps the command from generating an annoying message when fed an empty line. You need the double percent signs for shell variables inside batch files.

You can then use an at command to schedule when the batch file will run:

at 01:00 /every:m,t,w,th,f d:\users\davidk\kill_open_files.bat

An alternative way to perform this process is through Control Panel, Server, but you can’t schedule the process if you use this method. So try a “for /?” sometime and get familiar with its options. It’s a useful, robust command.

—David Krider
dunkirk@sprynet.com

Going Further

Did you know that Winzip can be called from the command line as well? (Or, at least, it could be, back in the 6.0 days…)

winzip32 -u -r -p d:allfiles.zip @d:\filelist.txt
ntbackup backup d: /a /r /l c:\windows\backup.log 

I liked using WinZip because the tape backup unit I had (an el cheapo Travan 1000) couldn’t do hardware compression, and `ntbackup’ couldn’t do software compression. Thus WinZip greatly sped up the process. I found, though, that because the tape drive was a floppy device, a parallel-port Zip drive would get 5 times the throughput, and that’s what I started using instead.

  • You may use these HTML tags: <a> <abbr> <acronym> <b> <blockquote> <cite> <code> <del> <em> <i> <q> <strike> <strong>

  • Comment Feed for this Post
Go to Top