From 5a5b8f998d21ae06a3762db0e5568e0af4f85134 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 8 Feb 2014 22:00:18 -0800 Subject: [PATCH] Handle case where there is only one job https://sourceforge.net/p/webadmin/bugs/4374/ --- bacula-backup/backup.cgi | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/bacula-backup/backup.cgi b/bacula-backup/backup.cgi index 65d6ceffd..5400eb729 100755 --- a/bacula-backup/backup.cgi +++ b/bacula-backup/backup.cgi @@ -15,18 +15,21 @@ $h = &open_console(); # Select the job to run &sysprint($h->{'infh'}, "run\n"); &wait_for($h->{'outfh'}, 'run\\n'); -$rv = &wait_for($h->{'outfh'}, 'Select Job.*:'); +$rv = &wait_for($h->{'outfh'}, 'Select Job.*:', 'OK to run.*:'); print $wait_for_input; -if ($rv == 0 && $wait_for_input =~ /(\d+):\s+\Q$in{'job'}\E/) { - &sysprint($h->{'infh'}, "$1\n"); - } -else { - &job_error($text{'backup_ejob'}); - } +if ($rv != 1) { + # Only need to enter a job if there is more than one + if ($rv == 0 && $wait_for_input =~ /(\d+):\s+\Q$in{'job'}\E/) { + &sysprint($h->{'infh'}, "$1\n"); + } + else { + &job_error($text{'backup_ejob'}); + } -# Say that it is OK -$rv = &wait_for($h->{'outfh'}, 'OK to run.*:'); -print $wait_for_input; + # Say that it is OK + $rv = &wait_for($h->{'outfh'}, 'OK to run.*:'); + print $wait_for_input; + } if ($rv == 0) { &sysprint($h->{'infh'}, "yes\n"); }