Jump to content

[SOLVED] Query working in Terminal but not in in the Run Script Action


Recommended Posts

Hi,

 

I am trying to build a workflow that converts a markdown file to a Word document with pandoc. The workflow creates a long string that serves as the pandoc command with all the arguments. Now when I take that string and simply run it in the Terminal, it all works wonderfully. So does running the string in the Terminal Command Action.

 

Now I obviously would like to replace the Terminal Command Action with the Run Script Action, only now the workflow does not work anymore? I deactivated all escaping (just like in the Terminal Command) and just have "{query}" as input, so I am not sure why it doesn't work now.

 

It is my first time scripting something with bash, so I am really not very knowledge with this. But as the very same thing works in Terminal but not in the Run Script Action I assume it's something Alfred-specific that I didn't consider?

Edited by armenaton
Link to post
9 hours ago, armenaton said:

"{query}"

 

With or without quotation marks?

 

It might be a PATH error (Alfred doesn't use the same PATH as your shell). Check Alfred's debugger.

 

Impossible to say for sure simply based on a description. When you have a question about a workflow, please upload it somewhere (Dropbox?) and post a link, so we can have a look at it for ourselves.

Link to post
4 hours ago, deanishe said:

With or without quotation marks?

I tried both. (And I tried running with bin/bash and bin/zsh, also tried argv and {query} and deselecting/selectign escaping characters)

 

 

4 hours ago, deanishe said:

It might be a PATH error (Alfred doesn't use the same PATH as your shell). Check Alfred's debugger.

Ah, I didn't knew Alfred had its own Debugger. Okay, I tried it and it reports as only Error "/bin/bash: pandoc: command not found". So I guess you are right about PATH? How do I tell Alfred the right PATH then? (sorry, it's my first time with bash)

 

 

4 hours ago, deanishe said:

Impossible to say for sure simply based on a description. When you have a question about a workflow, please upload it somewhere (Dropbox?) and post a link, so we can have a look at it for ourselves.

Sure, here is the workflow. Thanks for taking a look!

https://www.dropbox.com/s/72fdcj3c8an9xcv/pandoc.alfredworkflow?dl=0

 

Edited by armenaton
Link to post

Thanks. I can't run it because I don't have iA Writer, but I can see a few issues.

 

Don’t use “Run NSAppleScript”. Use a regular “Run Script” with Language = “/usr/bin/osascript (AS)” instead. Then you can read your variables using system attribute instead of faffing around trying to pass them in via ARGV.

 

In the AppleScript, you probably want to compose your shell command using quoted form of instead of trying to add quotation marks yourself.

 

You can’t just call pandoc in Alfred because it doesn’t use your shell’s PATH, so doesn’t look in /usr/local/bin. You need to use /usr/local/bin/pandoc instead of just pandoc.

 

To get your command to run in a Run Script with Language = “/bin/bash”, you’d have to set the Script to {query} (without quotation marks) and turn off all Escaping options.


Could you not just run it from your AppleScript with do shell script? Or just use AS to get the filepath and compose the command in zsh?

Link to post
14 minutes ago, deanishe said:

Don’t use “Run NSAppleScript”. Use a regular “Run Script” with Language = “/usr/bin/osascript (AS)” instead. Then you can read your variables using system attribute instead of faffing around trying to pass them in via ARGV.

 

In the AppleScript, you probably want to compose your shell command using quoted form of instead of trying to add quotation marks yourself.

Ah I see. Wasn't aware of those, will do, thanks.

 

15 minutes ago, deanishe said:

You can’t just call pandoc in Alfred because it doesn’t use your shell’s PATH, so doesn’t look in /usr/local/bin. You need to use /usr/local/bin/pandoc instead of just pandoc.

 

To get your command to run in a Run Script with Language = “/bin/bash”, you’d have to set the Script to {query} (without quotation marks) and turn off all Escaping options.

I see. Okay, now running it now results in another error:

"Error running filter pandoc-citeproc: Could not find executable pandoc-citeproc"

I assume it's because Alfred now knows the path to pandoc, but not to pandoc-citeproc? If so, how do I tell Alfred that it is simply also located in usr/local/bin/?

24 minutes ago, deanishe said:

Could you not just run it from your AppleScript with do shell script? Or just use AS to get the filepath and compose the command in zsh?

Tried do shell script, somehow didnt work either... (And I composed the command in AS because I was more familiar with AS)

Link to post
  • vitor changed the title to [SOLVED] Query working in Terminal but not in in the Run Script Action

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...