View Single Post
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:
strCmdToSend = "echo marry ; " & _
               "echo john ; " 

crt.Screen.WaitForString "$" 

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

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
' 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
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?
If Trim(strCommand) = "" Then Exit For
crt.Screen.Send strCommand & vbcr  <---- This looks wrong, to me.  
VanDyke Software
Technical Support
Reply With Quote