Scripting Question

How can I write a Script which asks for user input, then runs a specific command line shell script and adds the user input as a parameter when invoking that script?

So for example suppose I want to be able to run Applescript in Devonthink invoke script1.sh on my Desktop as /Desktop/script1.sh – “mycustomURL”

A good example is the “Import > Man Page” script, see ~/Library/Application Scripts/com.devon-technologies.think3/Menu/Import.

1 Like

Here’s a very simple snippet…

Note: You need execute permissions on the shell file for this to work: -rwxr-xr-x

1 Like

I tried an even simpler version but as you can see I am getting an error.

The bash shell script devonthink.sh works from Terminal - why not here?

What is your shell script?

The shell script is:

Why are you trying to start Node?

I am trying to start Node because I have an app in progress which imports data from Zotero to Devonthink by using indexed Dropbox files.

The Node app works when I activate it externally; it would be nice to be able to start it from wthin Devonthink however.

The issue isn’t with DEVONthink though.
I would suggest running the shell script on its own.

It does in fact work well on its own.

Is it not possible to have it acivate from a a script in Devonthink to make the workflow a bit easier?

What would be “easier” than just running the script directly? You could even put an alias in the dock.

And the issue isn’t “activating a script”. That, of course, is possible and is used all the time. You are talking about trying to run a particular bit of shell code in a do shell script AppleScript command. We exert no control over that behavior.

OK I will keep it external then - indeed it is in my dock now

Yeah, this is a case where there’s no real need to use an AppleScript.

BTW:
The “do shell script” command performs the script using sh. And the command’s parameter is the actual script, not a path to a script:

.

So is this closer to correct? (But still does not work)

While each of the lines is correct, it doesn’t work because setting the current directory in the first line has no impact on the second line.

So there is no way to do this inside of Devonthink - only by activating it externally?

you could try to do something like
do shell script "(cd workingdir; npm)"
in your AppleScript.

More on that topic: here