OSCmd
OSCmd is a library that enables easy shell command execution and system control across multiple operating systems.
OSCmd is currently released as a preview version. Feedback through issues or pull requests would be appreciated.
Features
- Platform-specific command execution (sync/async)
- Operating system information retrieval
- System controls
- Reboot
- Shutdown
- Sleep
Installation
- Open Package Manager from Window > Package Manager.
- Click the "+" button > Add package from git URL.
- Enter the following URL:
https://github.com/ctrl3d/OSCmd.git?path=Assets/OSCmd
Alternatively, open Packages/manifest.json and add the following to the dependencies block:
{
"dependencies": {
"work.ctrl3d.os-cmd": "https://github.com/ctrl3d/OSCmd.git?path=Assets/OSCmd"
}
}
UniTask Support
OSCmd supports UniTask for improved async operations. To enable UniTask support:
- Make sure UniTask is installed in your project
- UniTask support will be automatically enabled through the
UNITASK_SUPPORT
scripting define symbol
If UniTask is not installed in your project, OSCmd will fall back to using standard C# Tasks.
Usage
csharp using work.ctrl3d.OS;
var osCmd = new OSCmd();
string output = osCmd.Run("echo", "hello world");
// string asyncOutput = await osCmd.RunAsync("echo", "hello async"); // Async
///System control
osCmd.System.Reboot();
osCmd.System.Suhtdown();
osCmd.System.Sleep();
Contribution
Issues and PRs are always welcome!