Kin Pu
Kin Pu

Reputation: 430

How to run a script shell in google Colab for Swift?

I would like to run a shell command on Colab for Swift. I have tried all the python syntax options, and none work.

I have used the following prefixes:

!

%%

%%shell

Upvotes: 0

Views: 251

Answers (1)

korakot
korakot

Reputation: 40888

Call it via Python

import Python
let shell = Python.import("subprocess").getoutput
prefix func ! (_ command: String) {
  print(shell(command))
}

!"ls -al"

Upvotes: 3

Related Questions