Skip to main content
Participating Frequently
July 30, 2015
Question

Run shell script from javascript

  • July 30, 2015
  • 3 replies
  • 9606 views

Hi all,

anybody know if it's possible to run a shell command from within javascript? The ultimate goal is to place a javascript in the Scripts Menu of Photoshop that would run an applescript. I know you're going to say why not just do the script in javascript but the script I'm trying to execute does a lot more outside of PhotoShop. As an applescript is not accessible from the Scripts Menu I wandered if I could get a javascript to execute the applescript. The reason that Shell script is mentioned in the subject is because I can execute an applescript using a simple shell command of : osacript /path/to/the/script/file.scpt So if JavaScript can run the shell command I should be able to get it to work.

Thanks for looking,

Nik

This topic has been closed for replies.

3 replies

Known Participant
May 13, 2020

I am trying to do the same , when i am trying to call app.system("open '/Applications/example.app'")

I see below error TypeError: app.system is not a function. I want to open application using shell command from javascript

 

Kukurykus
Legend
May 13, 2020

app.system() is extendscript specific command.

Known Participant
May 14, 2020

Is there a way to call system calls from javascript?

Inspiring
July 30, 2015

app.system("osacript /path/to/the/script/file.scpt");

However, this is not a synchronous call. Depending on your apple script, it may continue to run after the function (app.system()) returns.

NAJAuthor
Participating Frequently
July 30, 2015

Many thanks for the response.

I tried running this command from within ExtendScript:

app.system("osascript '/Applications/Adobe Photoshop CS5/Presets/Scripts/Save_and_Join_v1.scpt'");

but it just causes PhotoShop to hang.

If I run this command in Terminal it works fine:

osascript '/Applications/Adobe Photoshop CS5/Presets/Scripts/Save_and_Join_v1.scpt'

Any ideas why this would happen?

Thanks,

Nik

Inspiring
July 30, 2015

Not sure why you are seeing the error. I suggest starting off with simpler .scpts and build up to see if that helps isolate the problem.

Chuck Uebele
Community Expert
Community Expert
July 30, 2015

I moved you're post to Photoshop Scripting forum.