How can I automate a script?

Hi All,

Can I automate a script when some one trying to 'vi' (open) a file.

For Example, I am having a file named 'SecuredShell.sh'.

when a user types " vi SecuredShell.sh " in unix command prompt a script named secure.sh needs to be automated.

Can this be possible. if Yes please guide me how to do that.

Thank you all in advance for your valid solutions!! :b:

Sorry, that was not clear.

did you mean to say a different script needs to be invoked when securedshell is opened via vi, then in that case, provide a custom script like yourVi and link to the actual vi.

Your question is not clear..
I think,this approach might help you. You can write a script which will keep on check whether any file opened thru vi. This can be checked thru ps command. If it is opened, then you need to take actions whatever you need.