#!/usr/bin/expect -f
spawn rsync -e "ssh -p 2222" -arvz
I suspect this syntax. -e ssh --port=2222 should be there without any "" double inverted commas
The below command works fine from command line: rsync -e "ssh -p 2222" -arvz --delete /var/www/html/ root@192.168.1.44:/var/www/html/