• (disco)

    One of our clients' application's database works exactly this way. Every user-written script that is run must be logged against a "scripts" log table, where the name of the script must be of the format "yyyymmdd_scriptname_versionno_sprintno". The last entry in this table should give you the version number.

    Fun fact: the application itself uses different version numbers than the database, so if you want to know if a certain instance of the database will be compatible with a certain version of the application, well, good luck.

  • (disco) in reply to Vault_Dweller

    That's still slightly better than looking in some random log file; databases are meant for data by definition.

  • (disco)

    Yes, in fact you're describing the most widespread implementation to maintain database schemas! That's for instance how Flyway works.

  • (disco) in reply to JBert

    The only difference being that the log file is in a database instead of on the file server?

  • (disco)

    Additional fun:

    ### ignore everything but Patches and Upgrades
    ### 'prev' indicates that a patch was uninstalled
    if ($item =~ "Patch" && $item !~ "prev" && $item !~ "rollback") {
        my @parts = split(/Patch\-/, $item);
        $checkver = $parts[1];
    }
    ...
    

    Apparently, if a patch was installed and then uninstalled, this will ignore the uninstall and still keep the patch version in $checkver

  • (disco)

    While mind-bending, the solution does work- until the application server starts running low on disk space, and the system admins decide to clean up the old logs...

    Or almost as bad, utterly fails to clean up old logs, leading to this crawling to a halt as it goes through everything else that's hanging around /var/log.

  • (disco) in reply to EatenByAGrue

    Well to be honest, there should not be that many different files there (some large files sure, but it is not looking in the content of the files). (On my Ubuntu system there is only 108 files, and that should not take that logn to go through)

    However that may in some cases be a dangerous assumption, especially if there are other systems which uses this brain-dead scheme.... .

  • (disco)
    my $rval = MyOwn::System::ls({ file => $path });
    

    I really hope this doesn't attempt to list the directory by running the ls program and parsing its output...

    my @things = split(/\n/, $rval->{'stdout'});
    

    Oh wait, it does. :disappointed:

  • (disco) in reply to Spectre

    And added bonus, it does not appear to provide absolute path for the ls comand either (making it possible for someone to potentially alter the path environment and supplying a 'spare' ls command which does just a bit more than plain old ls does.....) (unless that MyOwn::System:: thing which is not familiar to me indeed does provide full path)

  • (disco) in reply to Spectre
    Spectre:
    Oh wait, it does.

    To be fair, don't a lot of shell scripts do ls | cut? Not that it's a good way, but it's not like there's no precedent for that...

  • (disco) in reply to Maciejasjmj
    Maciejasjmj:
    Not that it's a good way

    I'm trying to think why they're doing it. Unless they're just getting the filenames out of ls -l, which would be quite thoroughly retarded.

  • (disco) in reply to dkf
    dkf:
    I'm trying to think why they're doing it. Unless they're just getting the filenames out of `ls -l``a`, which would be quite thoroughly retarded.

    Made that worse for you.

  • (disco) in reply to Onyx
    Onyx:
    Made that worse for you.

    ls -laRt would be worse.

  • (disco) in reply to dkf

    Eh, depends on how the loop is constructed on the t part, might not have any effect.

    R truly is evil though, and I am now hitting myself for forgetting that you can do that.

  • (disco) in reply to Onyx

    I threw the t in for giggles.

  • (disco) in reply to Yazeran
    Yazeran:
    it does not appear to provide absolute path for the ls comand either
    It defines $path as "/var/log" in the previous line. So it is using an absolute path.
  • (disco) in reply to Spectre
    Spectre:
    I really hope this doesn't attempt to list the directory by running the ls program and parsing its output...

    As opposed to what? opendir/readdir?

    We are talking about perl here! No one uses builtin functions when you can use MyOwn wrapper for a system command!

  • (disco) in reply to Scarlet_Manuka

    Yes it defines full path for /var/log, but NOT for /bin/ls

    If you use -T in perl it will not let you do a system() or backtics unless you have explicitly set $PATH to a untaintet string as relying on the environment is potentially dangerous

  • (disco)

    TRWTF is not only PERL: that all those if's were not just done as a single incomprehensible Regexp match....very un-Perl-ish.

Leave a comment on “Version Logging”

Log In or post as a guest

Replying to comment #:

« Return to Article