FTP automation with special characters in userid

Hi,
i am trying to automate an ftp script which is as below.But my user id has special characters(aaa\$ifg). So it is not working correctly.Can anyone help on this?I tried providing both of them in double & singe quoted. But somehow it is not picking the "\". Also tried keeping \ before the uid(aaa\\$ifg) and (aaa\\\$ifg).But no luck.

ftp -i -n ddd << end-of-session
binary
user aaa\$ifg password
put xyz.txt
bye
end-of-session

Have you tried using a .netrc file.
Format:

machine 192.168.1.1 login aaa\$ifg password abc123

Note that if you enter machine name as an ip address, you must use the ip address in the ftp command, and if you enter a domain name as the machine name, you must use the domain name in the ftp command.
Permissions should be 0400 or less, and located in your home directory.

Thank you jgt. That worked.But can't we do that using the script way of uid and password?

Thanks,

jgt's solution is brilliant and the preferred solution.
Untested but deducing from jgt's work using three backslash characters before the dollar sign may be what you need but the .netrc method is still the best.