in reply to Re: Firebird databases backup script
in thread Firebird databases backup script

@Anonymous Monk As I mentioned earlier I`ve tried both way in '' and "" and both don`t work.

But for different reasons. Using single quotes like that could never have worked, it would have never done what you are trying to do.

Also, as system documents, using system or die is wrong, you need to use system(@args)==0 or die.

or use autodie qw/ system /; and let autodie take care of the dying.

This means the actual command you're trying to execute is wrong -- I see some backticks which looks like an error to me.

What is the command you're trying to execute? What would it look like if you typed it in on the commandline, no variables, just the final text? Dumper it and see what you're trying to actually execute ( see

Tutorials: Basic debugging checklist for Dumper)

You might have better luck narrowing it down by giving system a list, as in

use autodie qw/ system /; my @args = qw[ ./gbak -user sysdba -password masterkey -BACKUP_DATABAS +E ]; push @args, "localhost:$data$_" , "$tempdir$_.gbk"; use Data::Dumper; print "Trying to system(@args) ", Dumper(\@args ), "\n"; system @args;

See systems for all the caveats, and use autodie, and when something doesn't work right, remember Basic debugging checklist

Replies are listed 'Best First'.
Re^3: Firebird databases backup script
by Mery84 (Novice) on Feb 29, 2012 at 11:36 UTC
    Hello,
    By hand gbak command looks:
    ./gbak -user sysdba -password masterkey -BACKUP_DATABASE localhost:/opt/databases/demo.gdb /opt/backup/demo.gdb.gbk
    and works fine.
    Also in simple script:
    chdir ($fbbin); system("./gbak -user sysdba -password masterkey -BACKUP_DATABA +SE localhost:/opt/databases/demo.gdb /opt/databases/demo.gbk")==0 or +die "Failed to create backup file \n";

    I see where is the issue with loading details from variables to system command but i don`t have any idea how to fix it.
    See:
    foreach (@files) { chdir ($fbbin); print "./gbak -user sysdba -password masterkey -BACKUP_DATABAS +E localhost:$data$_ $tempdir$_.gbk \n";
    Gives me output:
    ./gbak -user sysdba -password masterkey -BACKUP_DATABASE localhost:/op +t/databases/simplemarketing.gdb /opt/backup/simplemarketing.gdb .gbk
    This output should be in one row not in three ;). It looks like enter pressed always after $_ variable loaded from @files table which contains databases filenames. Any ideas how to fix it?