spawn tidak mendukung < arah tetapi Anda dapat melakukan seperti ini:
spawn sh -c "mysql -u root -h localhost -proot dbTest < temp.sql"
Sepertinya Anda ingin menjalankan mysql dengan cara non-interaktif sehingga Anda juga dapat menggunakan Expect system perintah:
system "mysql -u root -h localhost -proot dbTest < temp.sql"
atau Tcl exec perintah:
exec mysql -u root -h localhost -proot dbTest < temp.sql >@ stdout 2>@ stderr
Anda mungkin perlu meletakkan seluruh system atau exec perintah dalam catch blokir jika mysql gagal:
catch {system "mysql ..."} catched
# or
catch {exec mysql ...} catched