Expect Notes JOHN BECKETT 10202015 What is Expect
Expect Notes JOHN BECKETT 10/20/2015
What is Expect For? • Controlling command-line programs • Steps between the user and the CL program. • Handles prompts automatically • Packages user input and environment information so the CL program is handled correctly
What About TCL? • Expect does not have its own language – it uses Tcl • Everything is a string • Create variables with “set” • Use variables with $ (sounds like Bash). E. g. : $!/usr/bin/expect –f set name "Johnn“ send $name • Doesn’t send a carriage return unless you explicitly ask for it • set is Tcl • send is Expect
Expect Commands (keywords) Close debug disconnect exit exp_continue exp_internal exp_open exp_pid exp_version expect_after expect_background expect_before expect_tty expect_user fork inter_return interact interpreter log_file log_user match_max parity prompt 1 prompt 2 remove_nulls send_error sleep spawn strace stty system timestamp trap wait
Expect variables any_spawn_id argc argv 0 dbg error_spawn_id exp_library exp_exec_library expect_out interact_out send_human send_slow spawn_out spawn_id stty_init timeout tty_spawn_id
Tcl Commands after append apply argc argv 0 array auto_execok auto_import auto_load auto_mkindex auto_path auto_qualify auto_reset bgerror binary break catch cd chan clock close concat continue coroutine dde dict encoding env eof error. Code error. Info eval exec exit expr fblocked fconfigure fcopy fileevent filename flush foreach format gets global history http if incr info interp join lappend lassign lindex linsert list llength lmap load lrange lrepeat lreplace lreverse lsearch package lset parray lsort pid mathfunc pkg: : create mathop pkg_mk. Index memory platform msgcat platform: : shell my namespace proc puts next pwd nextto re_syntax oo: : class read oo: : copy refchan oo: define oo: objdefine regexp registry oo: object regsub open
- Slides: 6