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 | |
---|
13 | use strict; |
---|
14 | use warnings; |
---|
15 | |
---|
16 | use lib "$ENV{'ARBHOME'}/lib/"; |
---|
17 | use ARB; |
---|
18 | |
---|
19 | my $logged_amc = '_logged.amc'; |
---|
20 | |
---|
21 | my $gb_main = ARB::open(":","r"); |
---|
22 | if (not $gb_main) { |
---|
23 | my $error = ARB::await_error(); |
---|
24 | die "$error"; |
---|
25 | } |
---|
26 | |
---|
27 | my $macrodir = ARB::getenvARBMACROHOME(); |
---|
28 | if (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 | } |
---|
48 | ARB::close($gb_main); |
---|