Recover vmx from log file: Difference between revisions

Update to parse and retrieve vmx file from current vmware.log files.
m (typo)
(Update to parse and retrieve vmx file from current vmware.log files.)
 
Line 7: Line 7:


==== vmxRecover.pl code ====
==== vmxRecover.pl code ====
As of Fusion 4, the format of the vmware.log has changed. Here's the script for parsing log files from before Fusion 4
  #!/usr/bin/perl
  #!/usr/bin/perl
  use strict;
  use strict;
Line 25: Line 28:
     if (/: vmx\| DICT --- \S/) { last; } # Keep going until the next section
     if (/: vmx\| DICT --- \S/) { last; } # Keep going until the next section
     s/^.*: vmx\| DICT\s*//;    # Strip off the leading timestamp and other stuff
     s/^.*: vmx\| DICT\s*//;    # Strip off the leading timestamp and other stuff
    s/\r//;                    # Get rid of any \r's that may have somehow snuck in
    s/([^=]*=) (.*)/$1 "$2"/;  # Quote the value
    print;
}
New version to use for vmware.log files starting from Fusion 4:
#!/usr/bin/perl
use strict;
use warnings;
if ($#ARGV != 0) {
    print "Recovers .vmx files from .log files. Usage:\n";
    print "$0 logfile > vmxfile\n\n";
    exit;
}
while (<>) {
    # Scan until we reach the config section
    if (/: DICT --- CONFIGURATION/) { last; }
}
while (<>) {
    if (/: DICT --- \S/) { last; } # Keep going until the next section
    s/^.*: DICT\s*//;    # Strip off the leading timestamp and other stuff
     s/\r//;                    # Get rid of any \r's that may have somehow snuck in
     s/\r//;                    # Get rid of any \r's that may have somehow snuck in
     s/([^=]*=) (.*)/$1 "$2"/;  # Quote the value
     s/([^=]*=) (.*)/$1 "$2"/;  # Quote the value
1,274

edits