给你一个例子,注意发命令时加一个 : [code=BatchFile]#! /usr/bin/expect spawn su test expect { "Password:" { send -- "test "; }; "$" { send "ls / "; send "su root / "; expect { "Password:" { send -- "rootpw "; }; } exit; }; } [/code]
给你一个例子,注意发命令时加一个 : [code=BatchFile]#! /usr/bin/expect spawn su test expect { "Password:" { send -- "test "; }; "$" { send "ls / "; send "su root / "; expect { "Password:" { send -- "rootpw "; }; } exit; }; } [/code]