SPUG: One-liners on Windows via command.com

Tim Maher tim at consultix-inc.com
Wed Mar 23 16:36:09 PST 2005

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

	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?

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

> "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.
> 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!

| Tim Maher, PhD     (206) 781-UNIX      (866) DOC-PERL     (866) DOC-UNIX |
| tim(AT)Consultix-Inc.Com  http://TeachMePerl.Com  http://TeachMeUnix.Com |
|    Watch for my June, 2005 book: "Minimal Perl for UNIX/Linux People"    |

More information about the spug-list mailing list