Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-26-2017, 06:36 AM
pichi pichi is offline
Junior Member
 
Join Date: Oct 2010
Posts: 8
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.
Reply With Quote
  #2  
Old 12-26-2017, 09:47 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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
Reply With Quote
  #3  
Old 12-26-2017, 09:59 AM
pichi pichi is offline
Junior Member
 
Join Date: Oct 2010
Posts: 8
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.
Reply With Quote
  #4  
Old 12-26-2017, 10:28 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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
Reply With Quote
  #5  
Old 12-26-2017, 10:46 AM
pichi pichi is offline
Junior Member
 
Join Date: Oct 2010
Posts: 8
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.
Reply With Quote
  #6  
Old 12-26-2017, 10:47 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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
Reply With Quote
  #7  
Old 01-02-2018, 09:41 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hi pichi,

Quote:
4.- Insert the text previously copied by pressing the key combination of "shift and insert"
Are you attempting to paste what's in SecureCRT's clipboard? Or what's been "yanked" in vi?

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
Reply With Quote
  #8  
Old 01-04-2018, 05:40 AM
pichi pichi is offline
Junior Member
 
Join Date: Oct 2010
Posts: 8
Hello Brenda,

Thank you so much for your help on this, It worked and this task is now automated.

I appreciate it.
Reply With Quote
  #9  
Old 01-04-2018, 08:31 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hi pichi,

Great! Thanks for posting an update.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 03:58 AM.