[comment]: # ({e5a46c74-e5a46c74})
# script.getscriptsbyhosts

[comment]: # ({/e5a46c74-e5a46c74})

[comment]: # ({dfaa829b-dfaa829b})
### 説明

`object script.getscriptsbyhosts(array hostIds)`

このメソッドで、特定のホストで使用可能なスクリプトを取得できます。

::: noteclassic
このメソッドはどのタイプのユーザーでも利用可能です。このメソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。詳しくは[ユーザーの役割](/manual/web_interface/frontend_sections/administration/user_roles)を参照してください。
:::

[comment]: # ({/dfaa829b-dfaa829b})

[comment]: # ({080ad0f7-080ad0f7})
### パラメータ

`(string/array)` スクリプトを返すホストのID

[comment]: # ({/080ad0f7-080ad0f7})

[comment]: # ({1c891d1a-1c891d1a})
### 戻り値

`(object)` プロパティとしてホストIDを持ち、値として利用可能なスクリプトの配列を持つオブジェクトを返します。

::: notetip
このメソッドは`confirmation`テキストのマクロを自動的に展開します
:::

[comment]: # ({/1c891d1a-1c891d1a})

[comment]: # ({b41637d2-b41637d2})
### 例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({78b8a18a-4b630539})
#### ホストIDでスクリプトを取得する

ホスト"30079"および"30073"で使用可能なすべてのスクリプトを取得します

Request:

```json
{
    "jsonrpc": "2.0",
    "method": "script.getscriptsbyhosts",
    "params": [
        "30079",
        "30073"
    ],
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "30079": [
            {
                "scriptid": "3",
                "name": "Detect operating system",
                "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "7",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            },
            {
                "scriptid": "1",
                "name": "Ping",
                "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            },
            {
                "scriptid": "2",
                "name": "Traceroute",
                "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            }
        ],
        "30073": [
            {
                "scriptid": "3",
                "name": "Detect operating system",
                "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "7",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            },
            {
                "scriptid": "1",
                "name": "Ping",
                "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            },
            {
                "scriptid": "2",
                "name": "Traceroute",
                "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            }
        ]
    },
    "id": 1
}
```

[comment]: # ({/78b8a18a-4b630539})

[comment]: # ({a62657e4-a62657e4})
### ソース

CScript::getScriptsByHosts() in *ui/include/classes/api/services/CScript.php*.

[comment]: # ({/a62657e4-a62657e4})
