Jump to content
mikejandreau

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.

Share this post


Link to post

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.

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post
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.

Share this post


Link to post
1 hour ago, deanishe said:

Unless the commands are interactive you can.

 

I think might be.

 

5 hours ago, mikejandreau said:

using in Terminal and there's a ton of manual steps that they're doing.

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...