1-23
Cisco ASA Series CLI Configuration Guide
 
Chapter 1      Managing Software and Configurations
  Backing Up Configurations or Other Files
   $obj->clear_accum();
   $obj->send(“dir sdesktop\n”);
   $obj->expect(15, “$prompt#” );
   $output = $obj->before();
   return 0 if($output =~ /Error/);
   $cli=“copy /noconfirm sdesktop/data.xml $storage/$prompt-$date-data.xml”;
   $ocli=“copy /noconfirm $storage/$prompt-$date-data.xml disk0:/sdesktop/data.xml”;
   print “$cli\n”;
   print OUT “$ocli\n”;
   $obj->send(“$cli\n”);
   $obj->expect(15, “$prompt#” );
}
sub webcontent {
   $obj = shift;
   $obj->clear_accum();
   $obj->send(“show import webvpn webcontent\n”);
   $obj->expect(15, “$prompt#” );
   $output = $obj->before();
   @items = split(/\n+/, $output);
   for (@items) {
     s/^\s+//;
     s/\s+$//;
     next if /show import/ or /No custom/;
     next unless (/^.+\s+.+$/);
     ($url, $type) = split(/\s+/,$_);
     $turl = $url;
     $turl =~ s/\/\+//;
     $turl =~ s/\+\//-/;
     $cli = “export webvpn webcontent $url $storage/$prompt-$date-$turl”;
     $ocli = $cli;
     $ocli =~ s/^export/import/;
     print “$cli\n”;
     print OUT “$ocli\n”;
     $obj->send(“$cli\n”);
     $obj->expect(15, “$prompt#” );
   }
}
sub login {
    $obj = shift;
    $obj->raw_pty(1);
    $obj->log_stdout(0); #turn off console logging.
    $obj->spawn(“/usr/bin/ssh $user\@$asa”) or die “can't spawn ssh\n”;
    unless ($obj->expect(15, “password:” )) {
        die “timeout waiting for password:\n”;
    }
    $obj->send(“$password\n”);
    unless ($obj->expect(15, “$prompt>” )) {
        die “timeout waiting for $prompt>\n”;
    }
}
sub finish {
    $obj = shift;
    $obj->hard_close();
    print “\n\n”;
}