Issue custom Terminal commands from a Workflow

I think I’ve asked this question here before… but I didn’t get an answer and I can’t find the thread, so I’m trying again.

I’m a basic user of both Workflow and the Terminal. I run a CLI application called Google Admin Manager to, um, manage my Google Admin tasks :slight_smile: and I’d like to create some Workflows which will, upon launch, ask for some input and then use that input to issue commands to GAM in the Terminal.

This doesn’t seem like it should be that tricky, but I can’t get it to work.

Could someone show me how to build a simple “Hello World” Workflow that will do the following?

  1. Ask the user for their name
  2. Store the input into a variable called UserName
  3. Pass a command to the Terminal (echo hello UserName) so that the Terminal outputs a hello message to the user

Given that, I think I can puzzle out how to do what I need to do.

When you mention Workflow, are you referring to Shortcuts? Workflow was an app that Apple bought several years back and then rebranded as Shortcuts. It’s now available on the Mac as well.

Regarding integration with the GAM CLI tool, what you can do with Shortcuts or Scripting will largely depend on how the GAM tool works. I haven’t worked with it, but if it’s an interactive only utility, it’s doubtful that you’ll be able to integrate it with Shortcuts or shell scripting. If there’s a way for it to accept arguments to run specific tasks, then something could be put together.

To learn more about Shortcuts, you can take a look at the Shortcuts Field Guide that @MacSparky has put together or the Take Control of Shortcuts guide from @RosemaryOrchard. Both are paid sources, but likely would give you a ton of useful insight in how to build your own shortcuts going forward.

Here ya go:

Thanks… yes: I meant Shortcuts. Sorry, I’ve been noodling around with it since it was called Workflow and I confused the names.

GAM is not interactive: all I want to do is use Shortcuts to build a command then run it in the Terminal. An example: If I have to create a new user, I’d like to launch the New User Shortcut, and be prompted for “First Name”, “Last Name”, and “Personal Email.” I would then parse those inputs to produce a single command to run in the terminal as follows:

First: Clark
Last: Kent

Command: GAM create user firstname Clark lastname Kent othermail

So I want the shortcut to

  1. Collect the info
  2. Parse it to create my output (e.g. FirstInitial+LastName)
  3. Output a single, complete command to the Terminal

Thanks… one thing: that shortcut outputs within Shortcuts, not within the Terminal. I’m hoping that, after I run it, a Terminal window opens and the command runs.

I’m not sure what you are looking for then, as the commands are passed from Shortcuts to the Shell, the Shell runs them and then passes the results back to Shortcuts.

But it is the Shell that executes the commands.

And it turns out you had asked this question on the Automators forum:

This is the key answer from that thread (from Sylumer): “The terminal app is running an interactive shell where you could provide input, whereas the shell action in Shortcuts will run a non-interactive shell, executing a sequence of one or more preset commands. Since you are doing all the interaction in Shortcuts and just need the command executed, that should be just fine for your needs.”

Hope this helps.

Thank you for finding that older thread. I looked for it but could not locate it. :slight_smile:

…because I was looking in the wrong place.

1 Like