source: branches/properties/lib/macros/_dolog.amc

Last change on this file was 12178, checked in by westram, 11 years ago
  • create dated backups of previous recordings
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/usr/bin/perl
2#
3# auto-record ARB-session
4# (for debugging purposes; user could as well record ARB crashes)
5#
6# call via:
7# arb_ntree --execute _dolog database.arb
8#
9# rerun via
10# arb_ntree --execute _logged database.arb
11
12
13use strict;
14use warnings;
15
16use lib "$ENV{'ARBHOME'}/lib/";
17use ARB;
18
19my $logged_amc = '_logged.amc';
20
21my $gb_main = ARB::open(":","r");
22if (not $gb_main) {
23  my $error = ARB::await_error();
24  die "$error";
25}
26
27my $macrodir = ARB::getenvARBMACROHOME();
28if (defined $macrodir) {
29  if (not -d $macrodir) { die "No such directory '$macrodir'"; }
30  my $last_logged = $macrodir.'/'.$logged_amc;
31  if (-f $last_logged) {
32    my $backupDir = $macrodir.'/_backup';
33    if (not -d $backupDir) {
34      mkdir($backupDir) || die "Failed to create directory '$backupDir' (Reason: $!)";
35    }
36    my $modtime = (stat $last_logged)[9];
37    my $backup = $backupDir.'/_logged_'.$modtime.'.amc';
38    print "backup '$last_logged' -> '$backup'\n";
39    my $cmd = "cp -p $last_logged $backup";
40    system($cmd)==0 || die "Failed to execute '$cmd'";
41  }
42
43  BIO::remote_action($gb_main,"ARB_NT","macros");
44  BIO::remote_awar($gb_main,"ARB_NT","tmp/macro/file_name",$logged_amc);
45  BIO::remote_action($gb_main,"ARB_NT","MACROS/macro_record"); # hack :)
46  BIO::remote_action($gb_main,"ARB_NT","MACROS/CLOSE");
47}
48ARB::close($gb_main);
Note: See TracBrowser for help on using the repository browser.