View Single Post
  #12  
Old 03-20-2012, 04:12 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
The questions seem to be less about SecureCRT scripting and more about general VBScript statement construction. You may want to use MsgBox before sending strCommand just to make sure you know what strCommand looks like. I just tested a short script which looks very similar to yours, and it seems to work properly:
Code:
strCmdToSend = "echo marry ; " & _
               "echo john ; " 

crt.Screen.WaitForString "$" 

crt.Screen.Send "{ " & strCmdToSend & " } >> ./users.txt" & vbcr
Here's the output from the script:
Quote:
~/tmp $ { echo marry ; echo john ; } >> ./users.txt
~/tmp $ cat users.txt
marry
john
This is outside the scope of SecureCRT, but looking at your code I wondered about the following lines:

Code:
For Each strCommand in vCommands ' Exit the For..Next loop if our current command is empty...
' otherwise, we'll just be pressing the Enter key pointlessly.
If Trim(strCommand) = "" Then Exit For
crt.Screen.Send strCommand & vbcr
Next
' Wait for the command to complete before moving on to
' the next command
crt.Screen.WaitForString strPromptNext 
'1st commnad
crt.Screen.Send "echo " strCommand & " >> " & /disk2/users.txt" && vbcrcrt.Screen.WaitForString strPrompt
Next 
The first bolded line where you're sending strCommand with nothing else looks a little strange, as does the first bolded Next which follows.

Are you wanting to build up the complete command here instead of sending data?
Code:
If Trim(strCommand) = "" Then Exit For
crt.Screen.Send strCommand & vbcr  <---- This looks wrong, to me.  
Next
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote