stuartcryan Posted December 31, 2015 Share Posted December 31, 2015 Howdy all, have a bit of a conundrum. In one of the workflows I am developing, I have a script which needs to set an environment variable for OSX such as: set osascript to "/Users/stuartryan/Dropbox/AlfredSync/Alfred.alfredpreferences/workflows/user.workflow.EE2025D2-9836-4EF1-995D-B91C6A8D3377/passwordInput.osascript" However, in order to do this I need to be able to tell what the workflow directory is on each system. Is there any automated mechanism/variable to do this? (Using osascript). Alternatively the only other workaround I can think of is to check if a data directory exists for the workflow, and if not create it and "cat" a file there. Ideally I would copy the file over but I need to know where to copy it from first. Thank you all... this one is doing my head in so trying to find what the best supported solution is. Cheers, Stuart Link to comment
vitor Posted December 31, 2015 Share Posted December 31, 2015 What you’re looking for are Workflow Script Environment Variables. Also check how to access them with AppleScript (and other languages). Link to comment
deanishe Posted December 31, 2015 Share Posted December 31, 2015 When Alfred runs your workflow, it always does to from the workflow's own directory. That is to say, from any running workflow, the user's workflow directory is ../. Link to comment
stuartcryan Posted January 4, 2016 Author Share Posted January 4, 2016 What you’re looking for are Workflow Script Environment Variables. Also check how to access them with AppleScript (and other languages). WOOHOO exactly what I needed thank you. Link to comment
stuartcryan Posted January 4, 2016 Author Share Posted January 4, 2016 When Alfred runs your workflow, it always does to from the workflow's own directory. That is to say, from any running workflow, the user's workflow directory is ../. This is true, except for when you run something in Bash I have found, hence I need to be more explicit. Link to comment
deanishe Posted January 8, 2016 Share Posted January 8, 2016 This is true, except for when you run something in Bash I have found, hence I need to be more explicit. I don't understand. If you're not running your script from within Alfred, the Alfred environmental variables Vítor mentions above that are "exactly what [you] needed" won't be available… Link to comment
stuartcryan Posted January 9, 2016 Author Share Posted January 9, 2016 I don't understand. If you're not running your script from within Alfred, the Alfred environmental variables Vítor mentions above that are "exactly what [you] needed" won't be available… They are if I pass them through to bash. So basically I use a system command (perl) to run a command with Bash, but using the Alfred variables I am able to pass the data through that I need to that system command. Link to comment
deanishe Posted January 9, 2016 Share Posted January 9, 2016 Okay then. Just using the grandparent directory seems a lot simpler, however. Unless you're working with symlinks. Link to comment
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