|
![]() |
|
Thread Tools | Rate Thread | Display Modes |
#1
|
|||
|
|||
![]()
edit
edit edit edit edit edit edit edit edit edit edit edit edit edit edit Last edited by KentC; 05-03-2012 at 11:18 AM. |
#2
|
||||
|
||||
Hello KentC,
Most of what you're wanting to do could be done without any scripts. Sending e-mail upon detection of some error condition will require a script. For security reasons you may not want to embed a username and password in a script. SecureCRT's Session Options / Connection / Logon Actions provides Expect / Send capabilities. Using Expect/Send in Logon Actions allows you to hide the string you're sending (so your password doesn't need to sit in plain text in your script). If username and password are session specific, it makes sense to use Logon Actions for the session logon credentials. If you have the same username and password for all sessions and you don't care about security, it might be alright to leave the username and password in a script. When learning how to script with SecureCRT, it's a good idea to use the Script Recorder in the Script menu. It will help show the general sequence you should use: WaitForString, Send, WaitForString, Send. Always use WaitForString before Send (whenever you see two back-to-back Sends, you are almost certainly looking at a problem). Failure to WaitForString before issuing Send is by far the most common mistake you'll find discussed in our Scripting forums. Can you take a look at Logon Actions and see if the Expect/Send strings will be useful for you, at least for automating the logon process? Next, can you try the Script Recorder and manually walk through the steps you want to take (issue the commands, such as show clock, show call...), and when you're finished running the commands select Script / Stop Recording Script and see how much of the script the Script Recorder can write for you? In this case, looking for errors and sending e-mail should probably be added later, after you have a functioning script.
__________________
Mike VanDyke Software Technical Support [http://www.vandyke.com/support] |
#3
|
|||
|
|||
MikeD,
Thank you for your fast response! I'll test what you've requested and post back with the results and what else I'll need to include to automate this work project. Kent C. Last edited by bgagnon; 12-23-2011 at 03:17 PM. Reason: Removed blank lines |
#4
|
|||
|
|||
edit
edit edit edit edit edit edit edit edit edit edit Last edited by KentC; 05-03-2012 at 11:20 AM. |
#5
|
||||
|
||||
Hi Kent,
Looks good! I'm glad you decided to use the Logon Actions, plus a script. Hiding passwords in the Logon Actions rather than placing them directly in the script seems like a best practice. In your script, if you have three different machines then you'll probably need to change the WaitForString line from: crt.Screen.WaitForString "lax-sta4-gw1-as5300#"to something more general: crt.Screen.WaitForString "#" Another method which is very robust and reusable is to let the script detect the prompt (heuristically). If output from commands ends up containing the only non-unique part of all three prompts (e.g. '#') then this will be particularly important. The SecureCRT VBScript Scripting Manual has an example of heuristic prompt detection (see Section 7.2, page 92), and a lot of information and examples that I think you would appreciate. Quote:
In the Logging category you're already using variables for the log file name. I think you should add %m for minutes. Other variables you can use are listed in the Help file's Terminal/Log File section, in the Contents tab / Dialogs / Session Options Dialog / Terminal category. Using %m will help give a unique filename. All that's left is to automate the connection... see below. Quote:
You might use the Windows Task Scheduler, or schtasks, or the at command. You could also write a short script to kick it off. Look here for some script, schtasks, and at ideas. Here is an article specifically about using Task Scheduler to schedule a task every 15 minutes. If you used a batch file to start SecureCRT, you could use a one-liner, like this: "C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.exe" /T /S "Session 1" /S "Session 2" /S "Session 3" Quote:
How do you find the errors that you want sent in e-mail notification?
![]()
__________________
Mike VanDyke Software Technical Support [http://www.vandyke.com/support] |
#6
|
|||
|
|||
editeditediteditediteditediteditediteditediteditediteditediteditediteditediteditediteditediteditedit editeditediteditediteditediteditediteditediteditediteditedit
Last edited by KentC; 05-03-2012 at 11:21 AM. Reason: edit |
#7
|
|||
|
|||
Hi Kent,
Mike is out this week, but a colleague and I looked over the prior information in the thread. We noticed you are using Windows 7 (64-bit) and we think the SendEmail tip is outdated and likely only works on Windows XP. I have attached a newer version of that example script I think will be useful.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#8
|
|||
|
|||
editeditediteditediteditediteditediteditediteditediteditediteditediteditediteditediteditediteditedit editediteditediteditediteditediteditediteditediteditedit
Last edited by KentC; 05-03-2012 at 11:21 AM. Reason: made email and smtp more generic |
#9
|
|||
|
|||
Hello Kent,
I do not know the specifics of your script(s) well enough at this point to provide advice. First, you would simply want to make sure you can get the SendEmail example to work alone, then you can work on incorporating that functionality into the script(s) in progress. After changing SMTP server and port and the From/To addresses in the example script, were you able to send/receive a notification e-mail? I have not addressed parsing the logged data because debugging CDO object issues and parsing the logged data is getting a bit outside the scope of SecureCRT. So I might get a sense of your efforts to date, could you send log file(s) and copies of the scripts to support@vandyke.com? Please include "Attn Brenda - Forum Thread #10172" in the subject line.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Tags |
error , logon , vbscript |
Thread Tools | |
Display Modes | Rate This Thread |
|
|