use strict; use warnings; my @files; my @ext = (qw{fb gdb ib fdb}); my $data = "/opt/databases/"; # notice the final / foreach my $ext (@ext) { my @load = glob "$data*.$ext"; push (@files, @load); } foreach my $db (@files) { if (-f $db) { print "Found database: $db \n"; } else { print "skiping '$db'...\n"; } } # Alternatively: foreach my $ext (@ext) { my @load = glob "$data*.$ext"; foreach my $file (@load) { if (-f $file) { push (@files, $file); } else { print "Something is wrong, with '$file'!\n"; } } } foreach my $db (@files) { print "Found database: $db \n"; } #### use strict; use warnings; use IPC::Run3 qw( run3 ); my $FBUSER = 'SYSDBA'; my $FBPASS = 'masterkey'; # this is secret ;) my $gbak = 'gbak'; my $host = 'localhost'; my $db = '/opt/databases/test.fdb'; my $bk = '/opt/databases/backup/test.fbk'; # Backup the database on remote (or local) server my $cmd = qq{$gbak -backup -service "$host:service_mgr" "$db" "$bk" -user "$FBUSER" -pass "$FBPASS"}; run3 $cmd, undef, \my @out, \my @err; print "STDOUT: $_" for @out; if (scalar @err > 0) { print "\n--- Errors -------------------------------------------------\n"; print " $_" for @err; print "------------------------------------------------------------\n\n"; } else { print " Backup completed successfully.\n"; }