A pl2bat-style framework that logs it's own usage history. Consists of a .bat file perl script that checks for duplicates, and a snippet to add to the top of the target script.

I find this useful for recalling commands that I did on previous sessions, as MS doesn't have good command history facilities.

Only works for NT+ versions of Windows, due to "%~dpnx0" and "%*" functions. Can be replaced by "%0" and "%1 %2 %3 %4 %5 %6 %7 %8 %9" respectively for Win9X, but only if the script is the first find in the path by name, i.e. if you're in c:\ and run c:\phil\foo.bat, and there is a foo.exe in an earlier directory in the path, then you're on your own. I may do a 4Dos version some time but I seldom use perl on Win9X.

@rem = '--*-Perl-*-- @echo off perl -x "%~dpnx0" %* goto endofperl @rem '; #!/usr/local/bin/perl -w #line 8 my $line = $ENV{"LOGFOO"}; my $start=0; while (<>) { chomp; $start=1 if m|^:endofperl|; if ( $start and m|^::| ) { exit(0) if $_ eq '::'.$line; } } exit(1); # Not found __END__ Code to invoke is thus: set logfoo="%~dpnx0" %* call logfoo "%~dpnx0" if errorlevel 1 echo ::"%~dpnx0" %*>> "%~dpnx0" set logfoo= ... rest of batch script ... :endofperl

In reply to Self-logging .bat file by PhilHibbs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.