From a41dfdb6b29438a9b91ef5e2d0faf8b7f7b2a97a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Aug 2016 16:10:39 +0200 Subject: [PATCH] + enhance telnet options --- apps/protocols/telnet/mode/scenario.pm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/protocols/telnet/mode/scenario.pm b/apps/protocols/telnet/mode/scenario.pm index 09e34a43a..257ae9339 100644 --- a/apps/protocols/telnet/mode/scenario.pm +++ b/apps/protocols/telnet/mode/scenario.pm @@ -75,14 +75,19 @@ sub check_options { sub read_scenario { my ($self, %options) = @_; - my $content_scenario = do { - local $/ = undef; - if (!open my $fh, "<", $self->{option_results}->{scenario}) { - $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{scenario} : $!"); - $self->{output}->option_exit(); - } - <$fh>; - }; + my $content_scenario; + if (-f $self->{option_results}->{scenario}) { + $content_scenario = do { + local $/ = undef; + if (!open my $fh, "<", $self->{option_results}->{scenario}) { + $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{scenario} : $!"); + $self->{output}->option_exit(); + } + <$fh>; + }; + } else { + $content_scenario = $self->{option_results}->{scenario}; + } eval { $self->{json_scenario} = decode_json($content_scenario); @@ -171,7 +176,8 @@ Check telnet scenario execution =item B<--scenario> -Scenario used (Required) +Scenario used (Required). +Can be a file or json content. =item B<--timeout>