spawn understøtter ikke < retning, men du kan gøre sådan her:
spawn sh -c "mysql -u root -h localhost -proot dbTest < temp.sql"
Det ser ud til, at du vil køre mysql på den ikke-interaktive måde, så du også kan bruge Expect s system kommando:
system "mysql -u root -h localhost -proot dbTest < temp.sql"
eller Tcl 's exec kommando:
exec mysql -u root -h localhost -proot dbTest < temp.sql >@ stdout 2>@ stderr
Du skal muligvis sætte hele system eller exec kommando i en catch blokere i tilfælde af mysql mislykkes:
catch {system "mysql ..."} catched
# or
catch {exec mysql ...} catched