js-apis-application-shellCmdResult.md 1.3 KB
Newer Older
W
wusongqing 已提交
1 2
# ShellCmdResult

3 4
The **ShellCmdResult** module provides the shell command execution result.

W
wusongqing 已提交
5 6
> **NOTE**
> 
W
wusongqing 已提交
7 8
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.

9 10
## Usage

G
Gloria 已提交
11
The result is obtained by calling [executeShellCommand](js-apis-application-abilityDelegator.md#executeshellcommand) in **abilityDelegator**.
W
wusongqing 已提交
12 13

```js
G
Gloria 已提交
14 15 16
import AbilityDelegatorRegistry from "@ohos.application.abilityDelegatorRegistry";
let abilityDelegator;
let cmd = "cmd";
17 18

abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
G
Gloria 已提交
19 20 21
abilityDelegator.executeShellCommand(cmd, (err: any, data: any) => {
    console.info("executeShellCommand callback, failed: ", err);
    console.info("executeShellCommand callback, success: ", data);
22
});
W
wusongqing 已提交
23 24 25 26 27 28
```

## ShellCmdResult

Describes the shell command execution result.

29 30
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

W
wusongqing 已提交
31 32
| Name     | Type  | Readable| Writable| Description                                                        |
| --------- | ------ | ---- | ---- | ------------------------------------------------------------ |
33 34
| stdResult | string | Yes  | Yes  | Standard output content. |
| exitCode  | number | Yes  | Yes  | Result code. |