Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-12-2009, 07:15 AM
richardsugg's Avatar
richardsugg richardsugg is offline
Registered User
 
Join Date: Oct 2004
Location: North Carolina
Posts: 11
Need to send a literal brace

I need read a file that has curly braces in it and then send that to a text file via vi. When I do this with SendKeys, it interprets the { and } as delimiters for special characters rather than just curly braces. How do I get around this?

Example:

file myscript contains the following:
Code:
run_some_command | awk '{print $1}'
My SecureCRT script contains:
Code:
' read in myscript to the variable script_contents
script_contents = read_in_myscript

oScreen.SendKeys("vi bin/ne_creation_report" & vbCRLF)
oScreen.SendKeys("i")
oScreen.SendKeys(script_contents)
The last line works until it gets to the first curly brace, then complains that "print" is invalid. I don't want to embed the myscript into the securecrt script, where I would substitute chr(123) and chr(125) for { and } respectively.

Thanks,
Richard
Reply With Quote
  #2  
Old 10-12-2009, 11:02 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,439
Hi richardsugg,

To "escape" any special characters with 'SendKeys' you would actually have to enclose that special character in braces (ie: {{}).

See the 'ActiveX Scripting / Script Objects Reference / Screen Object' SendKeys method documentation in SecureCRT's help files for information on the set of special characters.

The information below is from VB Script's documentation on 'SendKeys':
To send bracket characters, send the string argument "{[}" for the left bracket and "{]}" for the right one.

To send brace characters, send the string argument "{{}" for the left brace and "{}}" for the right one.
However, this method is really intended to send special characters to simulate what you would type if physically on the remote machine (ie: pressing F7). For what you wish to do, I suggest the following:
Code:
Screen.SendKeys("vi bin/ne_creation_report~")
Screen.SendKeys("i")
Screen.Send(script_contents)
Does the above information help to accomplish your objective of sending the commands in your script to the remote?
__________________
Thanks,
--Brenda

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


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 04:04 AM.