SPUG: One-liners on Windows via command.com

John Costello cos at indeterminate.net
Wed Mar 23 17:21:45 PST 2005

On Wed, 23 Mar 2005, Tim Maher wrote:
> On Wed, Mar 23, 2005 at 02:08:55PM -0800, John Costello wrote:
> > On Wed, 23 Mar 2005, Tim Maher wrote:
> > [Tim's conundrum with command-line perl on Windows]
> > > 
> > > I had expected some indication that command.com wouldn't know what
> > > to do with the SQ, as opposed to an indication that Perl only got
> > > a single one in -e's argument!  Can somebody explain what SQs do in
> > > this shell?
> I've since surmised from reading "perldoc perlwin32" that

*cough* I missed perldoc perlwin32.  :-o
> 	perl -wnle 'print  "something"'
> Gets parsed as:
> 	perl -wnle  'print "something"'
> 	      arg1   arg2   arg3
> causing Perl to see "'print" as its entire program, which explains
> the Perl error message about a mismatched quote.
> > Be advised that "Start > Run > Command" and "Start > Run > Cmd" give you 
> > different command interpreters with different behavior as far as 
> > respecting full filenames vs. requiring 8.3 and a few other odd behaviors.  
> > I'll see if I can find a comparison of the two.
> On my XP system, command.com is only 50k in size, but cmd.exe is 380k,
> which so far is the only difference I've noted 8-}

> But maybe that difference is principally due to the .com vs. .exe formats?

No, I believe command.com is more closely related to the original dos 
shell (when you launch command.com, notice that it calls itself "Microsoft 
Windows DOS".

> > Start with 
> > 
> > 	help cmd 
> That provides some juicy info, but for me "help command" yields
> nothing but a "This command not supported by help" message.

Is there a requirement that you run the script under command.com, rather 
than cmd.exe?

> > "Learning Perl on Win32" says, on the topic of the command 
> > line, that one should check out the perlrun documentation.  perldoc 
> > perlrun does show MS-DOS specific examples. 
> Very little info there, but thanks for the reminder.

I forgot to mention that my reference is taken from LPW32 first edition, 
on my Perl CD Bookshelf 2nd edition (hope that made sense).

> > Select "Start > Help and Support".  
> > In the search dialog box, type "CMD" and hit the green arrow button.
> > Click on the suggested topic "CMD".  A page will display with info about 
> > CMD.
> > Scroll to the bottom of the page and click "Related Topics".  A dialog box 
> > will pop up.
> > Select either "Command shell overview" or "Command-line reference A-Z" and 
> > read them.  I think that is your best resource.
> I found "perldoc perlwin32" much more detailed and helpful; in contrast,
> these "help" pages seem to focus on the various switches, which I don't
> think are of much relevance to my quest to run Unix-ish one-liners on Windoze.
> > I also found interesting info from the following page (look under "Usage 
> > Hints for Perl on Win32")
> > <http://www.annodex.net/cgi-bin/man/man2html?perlwin32+1>
> That's good stuff, but it seems to be the same as "perldoc perlwin32"
> > John (running back to his *NIX perl)
> I don't blame you! 8-}
> Thanks for the pointers, John!

You are welcome!  Good luck!

> -Tim 

John Costello - cos at indeterminate dot net

More information about the spug-list mailing list