lftp does not perform globbing, unless you use the glob command so that the relevant line should read:
or eventually the mrm command which an alias for "glob rm":
Let me note that maybe you don't really need to use lftp if your only task is to remove files. Most likely you have ssh access together with ftp and the code above could be reduced to one single line:
Code:
ssh $user@$ip "rm $path/*$ext"
Also note that it's not a good idea to store a password in clear text inside a script. If you can (or have) set-up Public Key Authentication for password-less connections, you can still use lftp and leave the password blank, e.g.
Code:
lftp -u ${user}, sftp://${ip} << EOF
The same applies to the ssh command above, without modifications.