Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Julien_Matray
Participant

It is possible to run a script from repository using mgmt_cli ?

Hi,

It is possible to run a script from repository using mgmt_cli ?

My need is only run "read command" on gateways using run-script command.

I was thinking that put these read commands into script repository and allow my script user to run script from repository.

(i don't want my script user to run a cpstop command )

I was not able to find any informations about that.

Thanks

0 Kudos
4 Replies
_Val_
Admin
Admin

As far as I know, you cannot, but you can use run_script command with the commands you want to run:

Check Point - Management API reference 

0 Kudos
ilupashko
Explorer

Hello, i see that it have passed few years since this post was created, but it seems i have a similar problem.

I am trying to run a repository(managed in SC) script through mgmt_api to one of my target gateways. The contents of the script is simply "clish -c 'show configuration'". While i run it from SC - all is great, i see the expected "sho config" output. But from mgmt_api this same request: 

```
mgmt_cli run-script script-name "Show Configuration" script-type "repository" targets "gateway_object_name"

```

returns a b64 messageResponse, that when decoded shows something like:
```
APP PID STAT #START START_TIME MON COMMAND
FWK_FORKER 10547 E 1 [15:40:26] 12/10/2023 N fwk_forker
FWK_WD 10556 E 1 [15:40:27] 12/10/2023 N fwk_wd -i 6 -i6 0
CPVIEWD 10702 E 1 [15:40:45] 12/10/2023 N cpviewd
CPVIEWS 10707 E 1 [15:40:45] 12/10/2023 N cpview_services
SXL_STATD 10710 E 1 [15:40:45] 12/10/2023 N sxl_statd
...
...
```

Also this is shown in brief in description of task-details:
```
statusDescription: "APP PID STAT #START START_TIME MON COMMAND , FWK_FORKER 10547 E 1 [15:40:26] 12/10/2023 N fwk_forker , FWK_WD 10556 E 1 [15:40:27] 12/10/2023 N fwk_wd -i 6 -i6 0 , CPVIEWD 10702..."
```

It seems like my request is not even trying to get to specified gateway (changing from name to uid gives nothing)
Can you please point me to what I am doing wrong and how I can get a normal b64 response with "show config" output encoded there?
BTW The goal i try to reach is to get config(and not only) of each gate through web_api of SMS. Mgmt_api is just for low level tshoot, because trouble is the same.
Thank you!

0 Kudos
Maik
Advisor

Hey,

You can use the command "mgmt_cli run-script script-name <name> script <scriptname> targets.1 <target_machine_name> ...  --format json"

"..." equals more options that are possible to be referenced, like e.g. comments.

You can pick up more information here. If you want to execute scripts from the repository you should be able to do that by just specifying the path to the script within the <scriptname> parameter. Of course here the destination should be the SMS itself, as the repo is located locally there.

Edit: Seems like Valeri was faster than me, nvm.

0 Kudos
_Val_
Admin
Admin

lol

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events