in reply to Re: Getting values with help of curl
in thread Getting values with help of curl

Thanks! Is there any option to implement it just in the curl -s -k -u admin:pass https://url../GetDeviceInfo? So I can prompt it just with the console command?

Replies are listed 'Best First'.
Re^3: Getting values with help of curl
by Corion (Patriarch) on Sep 01, 2022 at 11:33 UTC

    I'm not sure what "it" is. If you simply want to change the URL, you can do that in the Perl code. But I'm not sure what your URLs are, or where the active=true part plays any role.

    I think it would help if you show us the two URLs you want and the behaviours you want. My current vague interpretation is that you want something like the following maybe:

    my $url = "https://url../GetDeviceInfo"; if( ... whatever condition ...) { $url .= "&active=true"; } say "Requesting $url"; my $output = `curl -s -k -u admin:password "$url"`; ...

      I can get the values in Postman as followed: management/api/v2/GetDeviceInfo?active=false. And since im new in the company and to programming I got the task to write a script that does exactly the same but in perl. As a hint I got the info that you can do it with help of curl and $ARGV and the code posted above can be shortend acording to my coworker.

      #Edit, got the solution, saving here for the future monks: my $content = system ("curl -s -k -u admin:pass https://url/management/api/v2/GetDeviceInfo?$ARGV[0]"); Upon typing perl test.pl active=true, prints every true value.

        system doesn't return the content, it returns the exit code. Therefore, your variable name is confusing.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]