how can I write script that lets me run shell commands?

Hello
I want to make simple extension to vi , you know how you want to run some shell command
you do ":! ls -l " , then you go out the vi the command executed and then you hit enter and you back to vi
but now I want to be able to go out of vi and run several command outside of vi .. and in some point hit some key and return back to vi .

I was thinking of execute perl script from vi that will let me run shell commands as in regular unix shell and then when I hit some key
the script will end and then I will go back to my vi session ( from where it all started )
my questions are :

  1. how can I do it in short perl script ?
  2. is there any easy way to do it without script?

thanks allot

This has worked for me. Not sure about its elegance.

When you are in vi, issue an Ctrl z. That will make vi go into the background. When you want to go back to the vi session, issue a fg.

hello
tnx for the fast reply , this is good idea ..
but if I would like still to execute the script as I like .. ( to add later on more opetions to the script )
how can I accomplish that ?

How about ":!ksh ./yourscript" (without the quotes) to run the script yourscript in your current directory. When yourscript exits it will return to vi (you may have to press RETURN first).

Also, you can just do ":!ksh" to start a new shell for command input. When you've finished type "exit" or "CONTROL-D" to return to vi.

cheers