How do I run a expect script in macOS Automator?

enter image description here

As it is possible to see in the picture, there is no such option

its a script of type:


  • what do you mean by picture ? – Ruskes Oct 1 '18 at 17:34
  • Welcome to AskDifferent, thank you for your post but it is more than a little unclear exactly what is going on. What is an "Expect Script?" If you can clarify and tell us (at least) what version of macOS you are running. Any more details on what is happening, what is expected and what troubleshooting steps you have already taken would also be helpful. – Steve Chambers Oct 1 '18 at 17:44
  • If expect script is some kind of shell, just select sh and invoke the expect script binary before running your command. – Wowfunhappy Oct 1 '18 at 18:03
  • The picture is the headers Automator give me to load with "execute shell script option". so, i would just select /bin/sh and then how can i run my expect script? i tryed select sh in dropdown window and then use "expect /absolute/path/to/my/script.sh" which is an expect script and did not work – Leonardo Benicio Oct 2 '18 at 12:24
  • 1
    You need to tell expect that it will read from a file. Either the shebang should be #! /usr/bin/expect -f and called directly or called as /usr/bin/expect -f /path/to/script. – fd0 Oct 2 '18 at 16:38

expect can be called from an Automator action but it must be indirect.

Within your Automator Run Shell Script action, call out to expect with something like:

expect -f /absolute/path/to/expect/script
  • I tried that but it just does not execute the expect script – Leonardo Benicio Oct 2 '18 at 12:25
  • Have you tested expect's exit status? Are you sure the path is correct? Does the command work when issued via Terminal.app? See stackoverflow.com/questions/951336/how-to-debug-a-bash-script for help doing this. – Graham Miln Oct 2 '18 at 12:46
  • 1
    yes, it works fine in terminal, unfortunately, didn't try printing debug messages on Automator, I will try to debug some msg in Automator and reply back – Leonardo Benicio Oct 3 '18 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .