Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with Powershell (or other terminal) #35

Closed
LeXuanKhanh opened this issue Jan 22, 2021 · 1 comment
Closed

Working with Powershell (or other terminal) #35

LeXuanKhanh opened this issue Jan 22, 2021 · 1 comment

Comments

@LeXuanKhanh
Copy link

Hi, is this possile to run powershell or other terminal in shell ? , it's seem like shell we are using on Windows is command prompt and I want run powershell on it by using run powershell or powershell.exe , since command on powershell is more similar to default terminal on Mac OS or Linux so I don't have to switch case base on the OS

I try and it open powershell successfully but after that I can't run any command on it, the controller don't send any event after I run powershell

I have looked this issue #29 , he could use powershell to send OS notification on Windows debug mode but only push once on release mode

My code:

  void test() async {
    controller.stream.listen((event) {
      print(event);
    });

    try {
      await shell.run('powershell.exe');
      await shell.run('pwd');
    } on ShellException catch (e) {
      // We might get a shell exception
      log('error');
      log(e.result.stderr);
    }
  }
@alextekartik
Copy link
Contributor

Shell is not a command prompt nor a scripting language, it only allows calling native binaries like you do in a console. And yes there are differences between platforms. However commands don't maintain a state, i.e. the command pwd in your example is not ran in the context of the previous powsershell.exe.

One solution is to call powershell with a list of command, or a script:

// You can run a command
await shell.run('powershell -c "pwd"');
// You can run a power shell script
await shell.run('powershell script.ps1');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants