Login into another user from user inside script

now i have logged in username : ramesh in unix
Now i have to created script file to login into another user and have run a command inside that user and after executing the command i have to exit from that user.
Inside script, i have to login into su - ram along with password : haihow and have to run chmod command. Any suggestions.

sorry wrong answer

@rammm Please post what Operating System and version you are running and what Shell you use.
Do you know the expect command?

@ methyl :I am using unix OS. The following are the version details,
Machine hardware: sun4u
OS version: 5.10
Processor type: sparc
Hardware: SUNW,Sun-Fire-15000

Yes

---------- Post updated at 02:12 AM ---------- Previous update was at 01:59 AM ----------

su - username -c "$chmod 770 a.txt"

I guess you're using Solaris 10, with kernel SunOs 5.10.
I don't know Solaris, but I've read you can download sudo or sudo-ldap packages from here:
Freeware for Solaris.

Then you'll edit your sudoers file (probably /etc/sudoers or /usr/local/etc/sudoers ) so that user ramesh can run chmod as haihow. man sudoers will help you.
Then you'll use something like sudo -u haihow chmod ... in your script.
--
Bye