Hi kgaudineer,
I don't think that you need a completely new script. I would likely add another condition after line 199. For example: Code:
If Instr(strCommand, "copy") > 0 Then |
Good afternoon rtb,
Thank you for the post... Unfortunately that won't help. These are prompts returned by the switch.... I am thinking it may just be easier to create a new script.. I have tried copying and pasting sections of this vbs script into a new one and that hasn't worked out either... My dilemma is there are several hundred of these switches I need to hit and it looks like this script has a hard time with a dynamic prompts.... Just out of curiosity is there any documentation on the commands used in Secure CRT. I downloaded a VBS book and other than the if, then, else, and case.... this book isn't much help for your VBS script. I did see the VBS FAQ but that's not much help either... I am looking for info on the commands and their arguments. For example... objNewTab.Screen.CurrentColumn -1 leaves me with 2 questions.... What is objNewTab and what does the -1 mean? |
Hi kgaudineer,
Quote:
Quote:
If you manually type the command all at once, what output do you see? Please post the output exactly as it would appear. If you need to redact sensitive data, replace each redacted character with an "x". Quote:
The scripting manual is a good place to start if you are learning. The variable objNewTab is an object. The internet has a wealth of information on learning object oriented programming concepts. Quote:
|
Good Morning RTB thank you for the reply...
to answer the first question these are the promps when trying to ftp the config In the line below Cisco-2960# is the prompt and copy startup-config tftp: is the command. following the command you must hit return Ciaco-2960#copy startup-config tftp: The line in red below is what is returned after hitting the return key. 10.24.21.117 is the IP of the tftpo server. must hit retunr to move on... Address or name of remote host []? 10.24.21.117 The line below is what is returned after presiing enter. The switch will use its host name as a suggestion for the filename. in all cases we want to keep the host name as the file name and add a .txt to the end of it... Destination filename [Cisco-2960-confg]? After pressing enter for the 3 rd time you swill see the output below. this indicates a successful config file transfer. !! 39344 bytes copied in 0.157 secs (250599 bytes/sec) Cisco-2960# The file I am working with I have commented out lines 215 & 216 and 259 Lines 215 & 216 are: ' Wait for the command to be echo'd back to us. g_objNewTab.Screen.WaitForString strCommand and Line 259 is: strResult = g_objNewTab.Screen.ReadString(strPrompt) The script does look like it will run most of the way through, however are having a problem with the last line feed. There is no more information that needs to be added and all that needs to be done is to just hit the return key. How do we put that as a command in the command file being read in? Also Is there a way to get one log file for each host instead of one log file for every command that is run? This command file has several lines of commands ... |
Hi kgaudineer,
Thanks for the information. Here is my understanding from what you posted. If you send the command copy startup-config tftp: the Cisco device responds with the following: Address or name of remote host []? 10.24.21.117Do you have to manually enter the IP address or is that automatically populated? After you press Enter, the Cisco device responds with the following: Destination filename [Cisco-2960-confg]?Do you just have to press Enter at this point? |
Good evening rtb,
following the first command copy startup-config tftp the Cisco switch will respond with: Address or name of remote host []?The IP address 10.24.21.117 needs to be manually entered or in this case its just a separate line in my commands file that is read. After entering the IP address press enter The switch responds with: Destination filename [Cisco-2960-confg]?The switch will automatically use its host name as the config file name. For us this is just fine so there is no need to change anything and we just press the enter key to accept the name as it is shown. |
Good morning rtb
I had a second thought this morning... Since there are basically only 3 commands that are being used for this task is there a way to comment out the section of the script that reads commands in from a separate file and just hard code the 3 file transfer steps ? My thoughts are trying it this way... copy startup-config tftp 10.24.21.117 waitfor string "#", "?" {enter} OR copy startup-config tftp://10.24.21.117/{variable to construct file name} {enter} waitfor string "#", "?" {enter} waitfor string "#", "?" {enter} |
Hi kgaudineer,
It seems like your idea would work. Were you able to successfully edit the script to use your idea? |
Good afternoon rtb,
I have not been successful in editing the script yet. Each time I try I break something else with the script.... My plan was to comment out this section starting at line 100.... ' Now call the ReadDataFromFile() function for the commands file. If Not ReadDataFromFile(g_strCommandsFile, _ g_strComment, _ vCommands, _ nCommandCount, _ nCommentLines) Then DisplayMessage "No commands were found in file: " & vbcrlf & _ vbtab & g_strCommandsFile Exit Sub End If There must be some other dependencies for this section because the error handling and the log file don't work correctly now.... |
Hi kgaudineer,
There are other dependencies. I am not sure how your script may be different, but in the unmodified script, it is lines 91 to 99 that read in the data from the commands file. The ReadDataFromFile() function definition begins on line 326. You can see that vCommands is an array that is passed by reference when the function is called to read the data from the commands file. After vCommands is populated with the commands to run, it is the foundation of the For Each...Next loop that starts on line 198. I think that rather than try and get rid of the commands file, it may be easier to add in a little code. If you were to use the concept that I suggested initially, you could modify the script to handle many different types of commands. The For Each...Next loop would look something like the following: Code:
For Each strCommand In vCommands Does this help you move forward in creating your script? |
Good afternoon rtb,
Thank you very much for the example. This is working out much better than trying to comment out the section. If I understand the explanation correctly. I can continue to add 'Else If' blocks just in case I come across a device that has a new prompt that I am not familiar with.... Is that correct.... |
Hi kgaudineer,
You are welcome. I am hoping that this discussion will benefit others that want to use this example and read this thread. I can see that my explanation is not very good. Adding additional ElseIf statements to the If...Then...Else condition would allow one to handle other interactive commands. For example: Code:
If Instr(strCommand, "copy") > 0 Then If you found another prompt that you needed to handle when trying to use the copy command, then you would need to modify the first If block. I can help explain how to do that, but I would need example output including the new prompt. Did you find a new prompt that you need to handle as a part of the copy command? |
Using Python Script
Quote:
telnet 1.1.1.1 password: ******** cisco> enable password : ******* Cisco# if we can't get a solution how can I ignore the prompt change. Thanks |
Hi iabudi,
Thanks for the post. What errors can you get if enable fails? What error do you see if the password is invalid? |
Python Script
Quote:
but I am running into a new issue where it runs the first command then stops at the prompt and when I stop the script it tells me its stoped at line 399 # Wait for the command to be echo'd back to us. g_objNewTab.Screen.WaitForString(strCommand + "\r\n") The window shows: Router-name# I not sure what is the script looking for? Thanks |
All times are GMT -6. The time now is 12:35 AM. |