Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
Programming Windows

For Automated Testing, Better Alternatives To DOS Batch Files? 426

Posted by timothy
from the run-them-under-wine dept.
An anonymous reader writes "I am working on a project that would allow our customers to test out sending different PCL commands to LAN printers. My initial thought was that a DOS batch file will allow users to select some simple options, send the tests to printers, and even generate a small web page which, when launched from the batch file, will provide email feedback on the tool. This all worked. To spice it up I added some ANSI color commands to the menus, though the implementation of that may prove tricky without resorting to .COM files or forcing the load of the ansi.sys via the command.com shortcut. And this implementation goes against my initial idea that I want the entire thing to be contained in a standalone batch file. My questions are: Is there a better option for this? Are DOS Batch files too 1990s to be taken seriously in 2010? The application needs to (1) be simple (2) be easy to update (3) be able to send PCL commands to LAN-attached printers and (4) allow email feedback. I don't know what other programming language would allow this and be as simple. I tend to think that I have found the best tool for the job but if you have another idea let me know. Call me crazy but I love DOS."
This discussion has been archived. No new comments can be posted.

For Automated Testing, Better Alternatives To DOS Batch Files?

Comments Filter:
  • perl? (Score:4, Informative)

    by FooAtWFU (699187) on Wednesday May 26, 2010 @05:38PM (#32354452) Homepage
    There's Windows ports of Perl, both Cygwin and ActiveState, last I checked.
  • Re:perl? (Score:1, Informative)

    by bi$hop (878253) on Wednesday May 26, 2010 @05:42PM (#32354518)
    But do your users have perl installed? If not, you'll need to "compile" it (e.g. with ActiveState's Perl Development Kit). This actually works quite well, but it's more effort than a simple batch file.

    That being said, if you've found the best tool for the job, why are you asking for ideas on slashdot?
  • Python (Score:3, Informative)

    by bmecoli (963615) on Wednesday May 26, 2010 @05:42PM (#32354524)
    Python is my scripting language of choice because it's easy to use and it has it's own "os" module that you can use to launch commands and the like, not to mention the "glob" module, which can grab all file names in a given directory into an array. I highly recommend it. (2.6)
  • AutoIt? (Score:5, Informative)

    by Anonymous Coward on Wednesday May 26, 2010 @05:43PM (#32354536)

    Its a great tool thats free, and has good GUI and has good scripting capabilities too:

    http://www.autoitscript.com/autoit3/index.shtml [autoitscript.com]

  • He's right. (Score:3, Informative)

    by Anonymous Coward on Wednesday May 26, 2010 @05:44PM (#32354564)

    For Windows platforms, there's nothing better for rapid prototyping than VB.NET - or really any of the .NET languages. Plus, you can get a version of Visual Studio from Microsoft for free that will do everything you want. Plus, you definitely won't regret having VS as a debugging environment.

    Think of how happy your customers will be to interact with a modern-looking app that only took you a few hours to put together!

  • dig your boldness (Score:3, Informative)

    by Crackez (605836) on Wednesday May 26, 2010 @05:44PM (#32354568)

    must be nostalgic for you or something...

    If it were me, I would put together what you need to work with Cygwin, then it could be cross platform. You could even ship a copy of cygwin.dll and any binaries you need, like bash, netcat, or what have you. I prefer Unix apparently.

  • by v1 (525388) on Wednesday May 26, 2010 @05:45PM (#32354572) Homepage Journal

    +1 agree. VB is RAD (rapid application development), is very flexible, and is easy to use to make standalone apps. if you like programming in dos, you will love VB. For the use you are suggesting, it sounds ideal. you can basically have it be the gui front end for things you need to be done in dos (via vb, you don't need a folder full of com files for it to use)

  • by Anonymous Coward on Wednesday May 26, 2010 @05:49PM (#32354598)

    Python is much easier to write and much more maintainable than a batch script. Unfortunately it can be unfeasible to require this dependency on Windows machines.

    Good dependency-free (albeit platform-specific) alternatives are .vbs (visual basic script) and .js. Both allow access to more modern dialog boxes etc. Either script should be executed under wscript.exe (windows scripting host) but I believe there is an automatic file association by default (at least for .vbs files).

    For a more modern alternative, try Powershell, however it is only present by default on Windows 7.

  • Re:perl? (Score:5, Informative)

    by BJ_Covert_Action (1499847) on Wednesday May 26, 2010 @05:53PM (#32354630) Homepage Journal
    Oh, I should caveat one thing. In order to develop perl scripts into a distributable, platform independent, one click executable, I've been using the PAR packager [cpan.org] module for perl. Sometimes it produces slightly bloated .exe's (since it has to bring in all of the relevant code from any external modules and dependencies), but it seems to produce very stable executables on win32 systems.
  • 4DOS! (Score:1, Informative)

    by Anonymous Coward on Wednesday May 26, 2010 @05:53PM (#32354632)

    It was extended to 8.00 by Luchezar Georgiev[1], and supports REXX interpreter, including free ones[2].

    [1] http://www.4dos.info/
    [2] http://www.4dos.info/dalter.htm#08

  • by Hatta (162192) on Wednesday May 26, 2010 @05:55PM (#32354654) Journal

    DOS sounds like "Boss" not like "dose".

  • Re:Python (Score:3, Informative)

    by lmpeters (892805) on Wednesday May 26, 2010 @05:55PM (#32354666)

    Python is my scripting language of choice because it's easy to use and it has it's own "os" module that you can use to launch commands and the like, not to mention the "glob" module, which can grab all file names in a given directory into an array. I highly recommend it. (2.6)

    Python also has a built-in "unittest" module that might make it a lot easier to manage your various test cases. I'd say if you can't count all of your test cases on one hand, you should take a serious look at that module.

  • Re:powershell (Score:3, Informative)

    by digitalunity (19107) <digitalunity@yahoo. c o m> on Wednesday May 26, 2010 @05:59PM (#32354710) Homepage

    It doesn't, but you can download it.

  • Re:Powershell (Score:2, Informative)

    by isThisNameAvailable (1496341) on Wednesday May 26, 2010 @06:07PM (#32354802)
    If DOS made you happy, then Powershell could drive you to orgasm if you let it. Object-oriented scripting that can tap into .NET, WMI, COM objects, Windows APIs, and still read/replace part of a text file in one line. You will have to install it on older clients, but what you want can be done with Powershell 1.0, which is like 2MB.
  • If you do use VB... (Score:5, Informative)

    by transporter_ii (986545) on Wednesday May 26, 2010 @06:11PM (#32354844) Homepage

    Did some quick research on it and it does look like it would work. But I did find this information:

    http://www.tek-tips.com/viewthread.cfm?qid=655463&page=6 [tek-tips.com]

    But here's the problem.... usually, when you use the printer object in VB to print with, it puts MORE PCL code round what you send (or PostScript, depending on the driver you use) and that messes the whole thing up.

    So one of my colleagues found a reference at MicroSoft on how to do what they call Raw Printng, which is direct to the printer not thru' the driver. We experimented with it and it does work. Here's the url: http://support.microsoft.com/support/kb/articles/Q154/0/78.asp [microsoft.com]

  • Re:He's right. (Score:4, Informative)

    by Anonymous Coward on Wednesday May 26, 2010 @06:14PM (#32354870)

    AutoHotKey or AutoIt are better and they are free unlike Visual Basic.

  • Re:I have a saying (Score:3, Informative)

    by Mr. Underbridge (666784) on Wednesday May 26, 2010 @06:19PM (#32354944)

    There are plenty of doges you can use, perl, python, bash, and lots more. But all of them add a level of complexity to this that the batch file doesn't have.

    What complexity does python add (for instance)? From the user's standpoint, if the .py file is associated with python (and it will be), double-clicking on the icon will run just like a batch file. And as pointed out, python can execute system commands too.

    I can see wanting to avoid cygwin, but python's a breeze.

  • by rubies (962985) on Wednesday May 26, 2010 @06:27PM (#32355038)

    I second VBS - asking a customer to install Perl is just asking for trouble unless you're in Unix land. The reason Bourne shell is popular isn't because it's particularly good, but because you know it (or a close variant) will always be available on any *nix.

    VBS isn't particularly nice to program in, but if you know what you're doing you can call most windows functions and even do database queries if that floats your boat. Networking stuff is a breeze and you can do a dialog based GUI if necessary.

  • by KevMar (471257) on Wednesday May 26, 2010 @06:28PM (#32355054) Homepage Journal

    I would also look to Powershell to solve his issue.

    Before Powershell, I would have went with VB Script.

    Because he was wanting a bit more of a GUI, HTA (HTML Application) would be a simple option. It is a local web page named .hta instead of .html and it runs with application security on the local computer. Any script you can put in a .vbs file, you can also put into a script block of a .hta. This is one of those little tricks that not to many people know about.

    I use hta when I want to keep the flexibility of html/script as an alternative to a compiled vb.net app.

  • Re:I have a saying (Score:3, Informative)

    by Nitrodist (1791378) on Wednesday May 26, 2010 @06:28PM (#32355056)

    I can see wanting to avoid cygwin, but python's a breeze.

    Except for the fact that python run-time libraries aren't included with Windows, yeah, great.

  • by ImprovOmega (744717) on Wednesday May 26, 2010 @06:42PM (#32355224)

    The biggest advantage of VBScript is its easy exposure of practically all COM API's on the machine. This lets you run a ridiculous amount of automation tasks from VBScript, but you are horribly limited in the sense that it's really not an object oriented language. It lacks ability to do pointers and even structs (C-style structs that is) making any kind of advanced data structures cumbersome to implement. But for scripting it's leaps and bounds above batch files *shudder* so I have to give it a nod for the original question.

    The one big problem with going GUI though is that its GUI objects do lend themselves to much customization. You cannot, for instance, create a list of buttons to pick from. You would almost want to use the cscript interface and go from there. That still embeds you in a DOS window, but hey.

    Also VBSEdit [vbsedit.com] is a killer IDE for developing VBScripts. It will even produce straight executables for you to help cut down on people breaking your plaintext scripts.

  • by shutdown -p now (807394) on Wednesday May 26, 2010 @06:49PM (#32355294) Journal

    Indeed, Active Scripting with VBscript or JScript is the only alternative if it has to run without any extra dependencies. It's available as a stock component from at least Win2K (I believe it's actually Win98, but can't be bothered to check; and I'm certain about Win2K). And while VBScript is ugly, JScript is a rather decent interpreted implementation of Ecma-262, and has enough hooks to do the stuff that is required here. And it's infinitely better than DOS batch files, that's for sure.

  • by Homr Zodyssey (905161) on Wednesday May 26, 2010 @07:25PM (#32355760) Journal

    I often write stuff like this using javascript or vbscript, and run it with "cscript". Its included in WinXP and later, so there's no installation required -- just a js or vbs script file. So, it would function much like your Batch file but you'd have a more descriptive language to work with.

    I do think vbscript is da debbil. However, it does have its uses when it comes to interacting with Office documents.

  • Re:He's right. (Score:5, Informative)

    by kelsey.grammer (83287) on Wednesday May 26, 2010 @07:45PM (#32355994)

    AutoHotKey or AutoIt are better and they are free unlike Visual Basic.

    Mod this up. I've used C++, Java, Perl, Ruby, vbscript, batch, and likely a few more to do this kind of thing in Windows over the years. For something this small I haven't found anything that beats AutoIt. It's so easy to learn and is fantastic for creating small, standalone executables with a GUI on Windows. This task is a perfect fit.

  • by Smallpond (221300) on Wednesday May 26, 2010 @07:54PM (#32356100) Homepage Journal

    http://search.cpan.org/~karasik/Win32-GuiTest-1.56/lib/Win32/GuiTest.pm [cpan.org]

    Perl has plenty of Windows-specific modules made for this type of application.

  • Re:dig your boldness (Score:3, Informative)

    by kybred (795293) on Wednesday May 26, 2010 @08:27PM (#32356476)

    You could even ship a copy of cygwin.dll and any binaries you need, like bash, netcat, or what have you. I prefer Unix apparently.

    Be careful [cygwin.com] about that.

    I use Cygwin myself, but copying the .dll for use with your app is fraught with peril.

  • by X3J11 (791922) on Wednesday May 26, 2010 @08:57PM (#32356836) Journal

    Actually.. cmd did not ship with every version of windows. Only since Windows 95. Prior to that, you required DOS, and DOS equivalent was command.com.

    Actually.. cmd did not ship with Windows 95. Only Windows NT got the native cmd.exe [wikipedia.org], which was compatible with command.com anyway.

    Make sure you're right when you're trying to correct someone else.

  • Re:He's right. (Score:1, Informative)

    by iwannasexwithyourmom (1804754) on Wednesday May 26, 2010 @09:26PM (#32357072)
    VB Express is Free, and probably much more powerful. (although I've never seen AutoIt so I can't have an opinion there)
    http://www.microsoft.com/express/Downloads/#2010-Visual-Basic [microsoft.com]
  • LabVIEW (Score:2, Informative)

    by CaptainPhoton (398343) on Wednesday May 26, 2010 @10:48PM (#32357674)

    Most electronics companies where I've worked or consulted use LabVIEW for automated product testing.

    You can download an eval copy from http://www.ni.com/labview/optin/trylabview

    LabVIEW is graphical programming. I'm still loyal to C/C++, but all those text languages are so 20th century! ;) Until we achieve natural language programming, LabVIEW is as good as it gets for 21st century.

    Putting humor aside, LabVIEW apps are very simple to write and deploy. The Application Builder allows you to create an EXE from your app and bundle it with the runtime in a nice Windows installer that you can send to your customers.

    I've seen some suggestions on here for PowerShell. One limitation of DOS batch files is the inability to interact directly with .NET. Anyone on modern Windows should learn .NET since it is the preferred framework now for that OS. PowerShell can give you the .NET access, but LabVIEW will have a much quicker learning curve if you ever have the urge to delve into .NET.

    The LabVIEW forums are very active, and the community gurus provide quick turnaround on support questions. For long-term maintenance of your test app, you're likely to find more engineers in the Test&Measurement arena that use LabVIEW versus DOS.

    Good luck in your choices!

  • Re:He's right. (Score:3, Informative)

    by Machtyn (759119) on Wednesday May 26, 2010 @10:49PM (#32357676) Homepage Journal
    I disagree. Use Tcl/Tk, Perl/Tk, or any other cross OS scripting language that contain a graphical toolkit. Using Tcl/Tk at my last job, I was able to create some nifty little utilities with a GUI, and I didn't have to worry about compiling. I also didn't have to install Tcl/Tk on each computer that was going to use it, as I used a wrapper to put it together for release.

    I still used the command shell fairly extensively when it was needed and I used C# when it was called for. Right tool for right job and all that.

    Windows Vista or later have a SUA [microsoft.com] (Subsystem for Unix Applications) and Powershell. While I have only just started looking into Powershell, it looks like a very good shell for Windows systems that finally (almost) brings it up to Linux/Unix standards of a shell.
  • Re:He's right. (Score:2, Informative)

    by MadKeithV (102058) on Thursday May 27, 2010 @04:15AM (#32359406)
    Mod parent up - Visual Basic *SCRIPTING* is free [wikipedia.org] on the windows platform.
  • Re:He's right. (Score:5, Informative)

    by teridon (139550) on Thursday May 27, 2010 @06:54AM (#32360238) Homepage

    AutoIt is nice -- the first time. That's how they hook you.

    Then, a year later, you decide to update your program. And hey, why not update to the latest version of AutoIt while you're at it? There was this one bug that always annoyed you, and you hope the devs fixed it.

    Well, guess what? While you had your back turned, all the APIs for the GUI changed. All those calls you made to AwesomeFunction() now require 4 arguments instead of 3. Oh, and one of them is now an object instead of string.

    That was my personal experience, anyway. After wroting a GUI program with perhaps 3000 lines of code, I updated to the new version of AutoIt. It seemed I had to practically rewrite the entire thing. Since then, I haven't recommended AutoIt to anyone that I like.

  • Anonymous Coward (Score:1, Informative)

    by Anonymous Coward on Thursday May 27, 2010 @07:08AM (#32360340)

    Use VBScript, not that complicated to pick up by looking at examples and RTM'ing the help file. Then use a HTA to present the interface, and even take feedback inside the HT

    http://technet.microsoft.com/en-us/scriptcenter/dd742317.aspx

    http://www.microsoft.com/downloads/details.aspx?familyid=01592c48-207d-4be1-8a76-1c4099d7bbb9&displaylang=en

  • by Just Brew It! (636086) on Thursday May 27, 2010 @09:05AM (#32361532)
    Where I work, we have used Python to create a regression and qualification testing framework for embedded avionics software. It has worked out exceptionally well. The testing framework was originally developed on Windows, but we are also porting it to Linux. (The Python parts are completely portable, of course... but because of the nature of the application we also had to create libraries in C to drive some specialized hardware, and the C modules do require some porting effort.)

Computer programmers do it byte by byte.

Working...