From aa8ee4278d36f969080d0ab30f2cd9d0ddb5f908 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 14 Sep 2017 09:37:45 +0200 Subject: [PATCH] Added export to JSON function to cli --- pandora_server/util/pandora_manage.pl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 34c42053e4..a34d918338 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -221,7 +221,7 @@ sub help_screen{ help_screen_line('--delete_visual_console', '', 'Delete a visual console'); help_screen_line('--delete_visual_console_objects', ' ', 'Delete a visual console elements'); help_screen_line('--duplicate_visual_console', ' []', 'Duplicate a visual console'); - help_screen_line('--export_json_visual_console', '', 'Creates a json with the visual console elements information'); + help_screen_line('--export_json_visual_console', ' []', 'Creates a json with the visual console elements information'); print "\n"; @@ -5070,7 +5070,7 @@ sub cli_duplicate_visual_console () { ############################################################################## sub cli_export_visual_console() { - my ($id) = @ARGV[2]; + my ($id,$path) = @ARGV[2..3]; if($id eq '') { print_log "[ERROR] ID field cannot be empty.\n\n"; @@ -5142,6 +5142,15 @@ sub cli_export_visual_console() { $data_to_json .= ']'; + if ($path eq '') { + open(FicheroJSON, ">console_" . $id . "_elements"); + } + else { + open(FicheroJSON, ">" . $path . "/console_" . $id . "_elements"); + } + + print FicheroJSON $data_to_json; + print_log "[INFO] JSON file now contents: \n" . $data_to_json . "\n\n"; } @@ -5596,7 +5605,7 @@ sub pandora_manage_main ($$$) { cli_duplicate_visual_console(); } elsif ($param eq '--export_json_visual_console') { - param_check($ltotal, 1); + param_check($ltotal, 2, 1); cli_export_visual_console(); } else {