#1
|
|||
|
|||
vi File editing and VBS scripting.
Hello all,
I want to automate editing a file using vi and of course scripting with VBS in secureCRT, I have some text copied already before running the script, so the tasks I need the script to perform are these 1.- open a file named "list" using vi vi list 2.- delete all of the contents of List file gD 3.- Press the "i" key i 4.- Insert the text previously copied by pressing the key combination of "shift and insert" 5.- save and close the file ESC key : key wq keys I know it is a very easy simple task however I am not able to do it, I have reach to the point where I want to insert the text in the file ( Shift & Insert keys press together), at this point it does not seem to work, it is not inserting anything in the file. Below are the few code lines I have. crt.Screen.Send( "vi sitelist" & vbCR) crt.Screen.WaitForString( "sitelist" ) crt.Screen.SendKeys( "d+gi") crt.Screen.WaitForString( "-- INSERT --") crt.Screen.SendKeys ("+{INS}") Can you please give me a clue how can I achieve this simple tasks? Thanks in advance. |
#2
|
|||
|
|||
Hi pichi,
Ctrl+Ins is SecureCRT's hotkey for paste, but is it vi's? If you change SendKeys() to send Ctrl+Shift+V, what are the results?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Hi bgagnon,
Thanks for your quick respond. As you suggested I tried replacing crt.Screen.SendKeys ("+{INS}") for send crt.Screen.Send (Ctrl+Shift+V) unfortunately it does not matter what I have copied it just pastes "0" on screen. |
#4
|
|||
|
|||
Hi pichi,
Sorry for the misunderstanding, but I still meant for you to use SendKeys, just change it to the hotkey representing vi's paste command. But I've been experimenting with the below and it does not seem to work either: crt.Screen.SendKeys "^+v" I also tried using the octal equivalent of Ctrl+Shift+V (\126) with Send() and no luck there either. Maybe someone out in the user community has some suggestions.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#5
|
|||
|
|||
Hi Brenda,
I forgot to mention when I do it manually it works fine. I do not know if I need to find another sequence for vi in order to get the text copied into the file. I will keep on searching. thanks. |
#6
|
|||
|
|||
Hi pichi,
Yes, manually I could also do either SecureCRT's or vi's paste, I just have not been able to find the right sequence to do with a script. ![]()
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#7
|
|||
|
|||
Hi pichi,
Quote:
If you want to paste what's in SecureCRT's clipboard, then this should work: crt.Screen.SendSpecial("MENU_PASTE")If you are trying to paste what's in vi's yank/put buffer, then I think you need to send (with vi in command mode, not insert mode) either a lower-case p or an upper-case P depending on where you want the yanked text to be put (p = put below; P = put above).
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#8
|
|||
|
|||
Hello Brenda,
Thank you so much for your help on this, It worked and this task is now automated. I appreciate it. |
#9
|
|||
|
|||
Hi pichi,
Great! Thanks for posting an update.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|