Need to modify a file of different username through script.

Hi ! All

I want to write a script where, it will open a new shell with a
username / pwd and modify a file of same username and exit.

example:

  1. UserA
  2. UserB- FileB

ScriptA -> su UserB -> Modify FileB -> Exit ScriptA

Can somebody give me a direction , on how to approach.

I did do some search in the forum, All were talking about Expect , Sudo .. etc.
Please help.
Thanks in advance. !!!

Where is the problem?

su user -c 'some operations;'

echo "EXIT";

Thanks you for replying.

But I dont want the script to prompt for password. I dont mind hard-coded the password .

The purpose , I have a file and I dont want anybody to modify it except me. In this case my script.

Did I make myself clear.