Any difference between "send_user" and "puts" in Expect?

pynexj picture pynexj · Dec 11, 2012 · Viewed 18.2k times · Source

I've been using Expect for a few years, but still it's not clear to me if send_user is the same as puts. Every time I want to send an informative message to the user, I wonder which one I should use. From Expect's man page, it seems like send_user is the same as puts but then what is send_user used for?

Answer

xolotl picture xolotl · Jan 26, 2013

Another difference I just discovered between the two, apart from the newline thing, is that if you're using log_file in your Expect script, statements sent via send_user will make it into the logfile, whereas statements sent with puts do not. If you're automating some Expect scripts which aren't being run on your actual console, that can make a big difference.