Skip to content
Advertisement

Expect script on linux

I would like to make a expect script which can answer the question by using srand functuon.

For example, I will use netcat to connect to the server, and I will get a question from server like “please enter 0 or 1”; then I hope my script can answer the question automatically by using the code like above.

JavaScript

If you can provide me some sample, it will be very helpful. Thank you very much.

Advertisement

Answer

You want to launch netcat, recognize that text, then return a random value in (0,1), yes?

JavaScript

See documentation: http://tcl.tk/man/tcl8.6/TclCmd/expr.htm and http://tcl.tk/man/tcl8.6/TclCmd/mathfunc.htm

Tcl’s expr command gets some flak for being a standalone mini-language inside Tcl. The syntax can be … cleaned up somewhat.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement