Getting The Process Id From A Spawn Id

While the spawn command returns a process id, Expect can provide this information at any time by using the exp_pid command. With no arguments, exp_pid returns the process id of the currently spawned process. The process id of a particular spawn id can be returned by using a −i flag. For example:

expect1.1> exp_pid −i $shell
20004

Do not confuse this command with pid. The pid command is a built-in Tcl command that returns the process id of the Expect process itself.

Get Exploring Expect now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.