Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 would 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?

like image 878
pynexj Avatar asked Dec 11 '12 07:12

pynexj


People also ask

What is Exp_continue in expect?

The command exp_continue allows expect itself to continue executing rather than returning as it normally would. By default exp_continue resets the timeout timer. The -continue_timer flag prevents timer from being restarted. (See expect for more information.)

How do you send Ctrl D in expect script?

You can type ctrl + V , ctrl + D to get the literal byte sequence in your expect script. Expect will then send this exactly as if you interactively typed ctrl + D .

What is TCL expect?

Expect is an extension to the Tcl scripting language written by Don Libes. The program automates interactions with programs that expose a text terminal interface. Expect, originally written in 1990 for the Unix platform, has since become available for Microsoft Windows and other systems. Expect.

What does expect do in Linux?

The Linux expect command takes script writing to an entirely new level. Instead of automating processes, it automates running and responding to other scripts. In other words, you can write a script that asks how you are and then create an expect script that both runs it and tells it that you're ok.


2 Answers

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.

like image 143
xolotl Avatar answered Nov 11 '22 12:11

xolotl


The main difference is that puts automatically appends a newline and send_user does not. In this regard, puts -nonewline is more analagous to send_user.

send_user also "inherits" some options from expect's send, such as -s and -h (check the expect man page for details). See http://99-bottles-of-beer.net/language-expect-249.html for a usage of the -h flag.

I cannot speak to how they're implemented at the C-level.

like image 23
glenn jackman Avatar answered Nov 11 '22 12:11

glenn jackman