in reply to reg ex and the prompt

Why not check the return value of spawn?

$test=Expect->spawn("/bin/sh") || die "Can't spawn /bin/sh:$!";

On a side note, shell prompts are completely configurable, they can go from:

#

to

[ user@host: 10:15pm: 12 ] ~/docs >

You'll need to be more specific as what you think the prompts will look like to generate a better regex.

HTH