#!/usr/bin/expect set timeout 2 spawn pseudoterm $env(PORT) sleep 1 expect { ">$" {} timeout { exit 1 } } send "some_definately_unknown_command\n" expect { "shell: command "some_definately_unknown_command" not found." {} timeout { exit 1 } } puts "\nTest successful!\n"