I didn't test this out but I think your problem is this line: if ('window -ex $amx_char_vwr') ... which should be: if (`window -ex $amx_char_vwr`) Notice the ' vs ` characters...