0

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.?

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by ghostdog74
0

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

0

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

0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.