hey friends,

I m in a process of automating Sudo test plan, where i need to invoke another shell within a shell automatically, then need to append a line into that script in sub-shell, then save it and quit from it..all automatically.
I m able to do evrything but not able to automate the process of saving and quiting from the sub-shell.

Is there any way to automate the "SAVE AND QUIT" [ :wq! ] process.?

It looks like you're trying to automate vi.

There are such things as "ed scripts" - scripts that invoke the ed editor.
You can use that scripting language easily. vi presents problems because it expects the terminal to be a tty, ed doesn't. Your stdin is a shell script.

man ed

Hey Jim,

thnx for the reply.
But the point is i need to do the sutomation in Vi only..!!
and still looking for the solution..!!

Anyways..i m still hopeful to find sm way out for this.
If u come across any sol. for this in Vi ...plz reply..!

thnx

why only vi? from the way i see, you just need to do something to a file and save it. So you can also use sed/awk to do the job.
If you still want to try vi, here's one way, not the best, but still does something.

sun# echo "test" > file
sun# more file
test
sun# vim -c "%s/test/changed" -c ":wq" file
sun# more file
changed
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.