David is right that this is usually a bad idea . Sometimes there are good reasons for this or something similar (for example, automatically logging into serial consoles to control shutdowns), but you have not provided any guidance as to why it makes sense for you to do it this way.
, invalid command name spawn, [sudo] expect. tcl, [] , . , , expect, glob, , [] . , , , , :
expect "\\\[sudo\\\] password for chronicles:"
, , , expect, .