How to write an expect script to check if a process is running?

I'm new to expecting and i want to create a script to ssh to a device,check is a process is running and display that the process is running or not.This is what i have so far
After executing this script i get an error.

#!/usr/bin/expect
set timeout -1
set ip "machine ip goes here"
set passwd "password goes here"
set pro "pgrep processtocheck | wc -l"
spawn ssh -p 222 machine@$ip
set test_id $spawn_id
expect -i $test_id "Password:"
send -i $test_id  "$passwd\r"
expect "ipcs"
send -i $test_id "sudo su\r"
expect -i $test_id "#"
send -i $test_id "$pro\r"
expect -i $test_id "#"
if { $pro -ne 1 } {
echo "process stopped"
} else {
echo "process running"
}
exit

Any help will be grateful

set passwd "password goes here"

You shouldn't use passwd as a variable name, it is a command.

See man passwd for info

thx for the mistake but I'm still getting an error when it comes to the if condition,any help on that?

if { $pro -ne 1 }
should this be { $pro != 1 }

Tried the changes but I'm still getting an error.

invalid command name "echo"
    while executing
"echo "process stopped""
    invoked from within
"if { $pro != 1 } {
echo "process stopped"
} else {
echo "process running"

Not sure of the "expect" usage , but "if" should be used something like this:

if [ $pro -ne 1 ];then
echo "done"
else
echo "not done" 
fi