How to call a shell command from JavaScript JXA?
Asked Answered
P

1

2

I have an AppleScript script that is calling a shell command that I want to convert to JavaScript (JXA) but I don't see the equivalent of do shell script.

Here is the script using AppleScript:

#!/usr/bin/osascript

on run argv

    set convertScript to "export -i '" & first item of argv  & "' -o '" & second item of argv & ".csv'"

    do shell script convertScript

end run

My desktop application calls this script and then the script executes the shell command.

Playsuit answered 11/1, 2018 at 6:41 Comment(1)
Similar question: #28045258Thaumatology
P
5

It is possible using the following command:

var app = Application.currentApplication();
app.includeStandardAdditions = true;
return app.doShellScript('ls');

From here.

Playsuit answered 11/1, 2018 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.