Marc Posted February 11, 2023 Posted February 11, 2023 (edited) I have an Applescript which I have copied to my workflow folder. I followed the tips from this post The preference in Alfred to "Run AppleScripts instead of opening" (found in: "Alfred Preferences -> File Search -> Advanced -> AppleScripts [ ] Run AppleScripts instead of opening) modified permissions of .scpt file with Terminal using `chmod +x myFile.scpt` Used a RunScript Action and entered Filename. File is recognized (if I click on open file it opens the correct script). When I now try to execute the workflow I get the error: Unable to run task! Reason: Couldn't posix_spawn: error 8 What am I doing wrong? I am still new to using Alfred with scripts. Another question is how can I get the query (a string) into the script for further processing by the script? Thanks Edited February 11, 2023 by Marc
vitor Posted February 11, 2023 Posted February 11, 2023 2 hours ago, Marc said: The preference in Alfred to "Run AppleScripts instead of opening" (found in: "Alfred Preferences -> File Search -> Advanced -> AppleScripts [ ] Run AppleScripts instead of opening) That doesn’t affect this case. 2 hours ago, Marc said: What am I doing wrong? Impossible to say because all relevant information is blurred and the workflow was not shared. Without information we cannot know what is wrong or how it needs to be fixed. 2 hours ago, Marc said: Another question is how can I get the query (a string) into the script for further processing by the script? When using External Script in a Run Script, the arguments are set from the output of the previous object. Alternatively, give the arguments yourself by calling the the script with e.g. /bin/zsh.
Marc Posted February 11, 2023 Author Posted February 11, 2023 (edited) Hi Vitor, thanks for helping again. I blurred the username in permission list ("marc") and the scriptname ("myscript") for privacy reasons. I used the exact filename in theRun ScriptFilter. And Alfred also recognizes the correct file. Since it opens when I click Open file. Username of files in filelist and in path of error message are the same. Edited February 11, 2023 by Marc
vitor Posted February 11, 2023 Posted February 11, 2023 Without inspecting the workflow itself it’s not possible to help further. If you don’t want to share the real one you can create a smaller use case which still causes the problem and share that. Think of it like taking your car to a mechanic; you can show them pictures and describe the issue, but some problems require looking under the hood ourselves and poking around to see what’s wrong.
Marc Posted February 11, 2023 Author Posted February 11, 2023 (edited) I just created a workflow which you can find here. The script reads data from a CSV file. After that some text substitutions and calculations take place (omitted in the example workflow attached). At the end the results should be passed as variables for further use in Alfred. Edited February 11, 2023 by Marc
vitor Posted February 11, 2023 Posted February 11, 2023 You’re saving the code as a compiled AppleScript. That is no longer a script. You have to save it as text and add a shebang at the top: #!/usr/bin/osascript
Marc Posted February 12, 2023 Author Posted February 12, 2023 Ah ok. I thought I can just copy the file to the workflow folder. After copying the code over to a text I had some error messages since the formatting was messed up. So it took me a while to test and give feedback. Script gets now executed without throwing the earlier error message. But I cant get the variable I set with a Var Object in the script. I get an error s_nr not defined. If I hardcode a s_nr for testing in the script it works as expected but I need the s_nr to be dynamic from the query. Sorry for the newby questions I am still learning how to combine Alfred with scripting. And thanks again for your help.
vitor Posted February 12, 2023 Posted February 12, 2023 See the Reading Environment Variables documentation. Marc 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now