Forum Archive

Is it possible to run external file scripts from Shortcuts?

DavidFernas

As title, I'd like to trigger a script which I've opened from Working Copy. What's the smoothest way to achieve this?

I'm aware that it's possible to open files that are in iCloud Drive via an iOS deep link, but couldn't find a similar workaround for external files.https://reversephonelookup.onl/ https://curated.onl/nba-reddit/ https://pcbuilder.onl/pcpartpicker/

Thanks in advance!

cvp

You could, via Shortcuts, launch a little Pythonista script running in Python2
and launching it-self your external file script in Pythonista3

Tested and ok:

#!python2
from objc_util import *
dir = '/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/.../xxx.py'
arg = ''
#dir = os.path.expanduser('~/Documents/'+app)       
I3=ObjCClass('PYK3Interpreter').sharedInterpreter()
# run a script like in wrench menu (path, args, reset env yes/no)
I3.runScriptAtPath_argv_resetEnvironment_(dir, [arg], True) 
cvp

I'm (almost) sure you could even pass the external script url as argument of little script, not tried

bhaiterabhai

We make use of the Safari web browser, running within the shortcut, in order to execute the JavaScript. To do so, we:

make an HTML file that contains our code and provides an output;

pass the contents of the file to Safari as a Data URL;

use Get Contents of Web Page to render the page provide the output to the shortcut. shareit vidmate

flisterfour

Technically, you don’t even need an and to run code. Safari will wrap