Jump to content

Getting value from Terminal?

Recommended Posts

I'm looking to build a Workflow that effectively does a series of things in Terminal.


My idea is to trigger the Script with a keyword which triggers action 1 in Terminal.

Action 2 would run once Action 1 completes.


I haven't been able to find any docs on whether or not that's possible.


For example, let's say Action 1 is generating a .tar archive of everything in a directory and Action 2 is moving the .tar to a subdirectory (or something else). Can Alfred know when the first Action is done to kick off the second? (I know I can do the .tar generation and move in one command - that's not what I'm actually doing here, but is just an example of something that came to mind for having Alfred know the first thing's done before doing the second thing.)


Hoping it's possible, but I don't think it is.

Link to comment

Why are you trying to do these actions in a terminal instead of running a script? Seems like what you want is to execute a sequence of commands. A Run Script Action is more appropriate — it’s faster and doesn’t need to call a Terminal.


If you indeed need to call a Terminal, we’ll need to know why and know what exactly you’re trying to accomplish. Else it’s just and XY problem, which won’t lead to the optimal solution.

Link to comment

I'm running in Terminal so that I can know if there's an error of some kind during any of the steps. Since we're connecting to a number of APIs, including S3 and our own, there's a possibility of some sort of error.


I was given a set of instructions folks are using in Terminal and there's a ton of manual steps that they're doing. I was hoping to simplify it with a workflow.


I don't know if I could script something to perform the same actions with a Run Script Action, but I'll take a look at those docs and give it a whirl.

Link to comment

Why not include all your steps in the same Terminal Command? Each step only runs after the previous one exits; there won’t be any overlap, or anything.


You can also connect an External Trigger to your second step. Then, on the Terminal command of your first step you tell it to call the External Trigger at the end. You can do so with something like osascript -e '{{sample code from the External Trigger}}'. But if all you’re doing is running Terminal commands, the solution in the previous paragraph is more straightforward.

Edited by vitor
Link to comment
3 hours ago, mikejandreau said:

I don't know if I could script something to perform the same actions with a Run Script Action


Unless the commands are interactive you can. If the programs are well written, they will exit with a non-zero status if there's an error. The exit status is simple enough to check in a script, in which case you can show a notification/large type/something else.

Link to comment

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...