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

[Question] Support for other shells #1584

Closed
Stephanevg opened this issue May 26, 2021 · 2 comments
Closed

[Question] Support for other shells #1584

Stephanevg opened this issue May 26, 2021 · 2 comments

Comments

@Stephanevg
Copy link

Stephanevg commented May 26, 2021

Hi all,

I do have a quick question, what is the support for 'other shells' currently in digDag.
I am particularly interested in Powershell, as it is the defacto scripting language for many engineers with a Windows background.

I read [on your documentation here] (http://docs.digdag.io/operators/sh.html?highlight=powershell) that there is some powershell support, but only for a DigDag instance that would have been installed on Windows box.

Microsoft has open sourced powershell and made powershell cross platform, it runs on a lot of other platforms than just Windows. (See here for the list of available Os's).

How would it work if we would like to powershell from a digdag instance installed on a Linux box?

On windows, powershell.exe must be used, but on linux (and macosx for that matter) one needs to use pwsh to exectute a powershellscript.
example: pwsh .\myscript.ps1 would execute the myscript.ps1 file on mac or linux.

Internals

How does DigDag actually work regarding these things internally?

In your examples page, you guys have the following example for bash

export:
  sh:
    shell: ["/usr/bin/zsh"]

+step1:
  sh>: tasks/step2.sh

and the following example for powershell (on windows box)

_export:
  sh:
    shell: ["powershell.exe", "-"]

+step1:
  sh>: step1.exe

+step2:
  sh>: step2.ps1

Base on these examples, it seems to me we could specifiy and shell, am I right? Would something like this work?

_export:
  sh:
    shell: ["/usr/bin/pwsh"]

+step1:
  sh>: step1.exe

+step2:
  sh>: step2.ps1

If not, is that something you guys are considering? What should be changed for this to even be possible?

@hiroyuki-sato
Copy link
Contributor

Hello, @Stephanevg

I'm not familiar PowerShell. But you can use PowerShell using pwsh -File.

test.dig

+task1:
  sh>: pwsh -File hello_digdag.ps1

hello_digdag.ps1

write-output 'hello powershell'
write-output $PSVersionTable.PSVersion.Major
digdag run test.dig
2021-05-26 19:36:07 +0900: Digdag v0.10.0
2021-05-26 19:36:10 +0900 [WARN] (main): Using a new session time 2021-05-26T00:00:00+00:00.
2021-05-26 19:36:10 +0900 [INFO] (main): Using session /private/tmp/hogehoge/.digdag/status/20210526T000000+0000.
2021-05-26 19:36:10 +0900 [INFO] (main): Starting a new session project id=1 workflow name=test session_time=2021-05-26T00:00:00+00:00
2021-05-26 19:36:10 +0900 [INFO] (0017@[0:default]+test+task1): sh>: pwsh -File hello_digdag.ps1
hello powershell
6

@hiroyuki-sato
Copy link
Contributor

I don't recommend this way. But as described in the Windows part, you can switch to the pwsh shell.
Please close this issue when you solve it. And you need to case #1560 if you run Digdag on the Windows platform.

+task1:
  sh>: ./hello_digdag.ps1
  shell: ["pwsh","-"]

@yoyama yoyama closed this as completed Dec 22, 2022
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

3 participants