VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   how to stop logging accurately?? (https://forums.vandyke.com/showthread.php?t=10400)

xujunmao 04-09-2012 03:25 AM

how to stop logging accurately??
 
2 Attachment(s)
Hi Todd,

here is part of my script, We get log file results is NG.txt[http://forums.vandyke.com/attachment...&d=1333963380], but we need like OK.txt[http://forums.vandyke.com/attachment...&d=1333963380]

lngResponse = vbyes

Do While lngResponse = vbyes
crt.Session.Log True, True
crt.Screen.Send vbcr
crt.Screen.WaitForString "]:"
crt.sleep 500
crt.Screen.Send "m" &vbcr
crt.sleep 100
crt.Screen.WaitForString "host ip address:"
crt.Screen.Send "192.168.4.20" &vbcr
crt.sleep 100
crt.Screen.Send "wrs" & vbcr
crt.sleep 100
crt.Screen.Send "wrs" & vbcr
crt.sleep 100
crt.Screen.Send "microcode.bin" & vbcr
crt.sleep 100
If crt.Screen.WaitForString ("Do you want to update image file?<Y/N>",3) <> True Then
Call WriteLog(g_Server_LogFilePath, "Fail")
crt.Session.Log False
exit sub
End If
crt.Screen.Send "Y" & vbcr
crt.sleep 100
crt.Screen.WaitForString "success."
crt.Screen.WaitForString "microcode update success.please reboot system for taking effect."


'os file
crt.Screen.Send vbcr
crt.Screen.WaitForString "]:"
crt.sleep 500
crt.Screen.Send "u" &vbcr
crt.sleep 100
crt.Screen.WaitForString "please input mode choose..."
crt.Screen.Send "2" & vbcr
crt.sleep 100
crt.Screen.WaitForString "host ip address:"
crt.Screen.Send "192.168.4.20" &vbcr
crt.sleep 100
crt.Screen.Send "wrs" & vbcr
crt.sleep 100
crt.Screen.Send "wrs" & vbcr
crt.sleep 100
crt.Screen.Send "opcom3500Enms-B.z" & vbcr
crt.sleep 100
crt.Screen.WaitForString "Do you want to update image file?<Y/N>"
crt.Screen.Send "Y" & vbcr
crt.sleep 100
If crt.Screen.WaitForString ("success.",30) = False Then
Call WriteLog(g_Server_LogFilePath, "Fail")
'record file
crt.Session.Log False
Exit Do
End If
Call WriteLog(g_Server_LogFilePath, "Success")
'record file
crt.Session.Log False
g_WshShell.Popup g_msg_pass, 1, "TEST STATUS~~!", 64
Loop

rtb 04-09-2012 11:13 AM

Hi xujunmao,

Thanks for the question. I see in your script that you are calling WriteLog() with a global variable g_Server_LogFilePath.

Can you post the function and where you define the path?

It seems like you want to log the session, and then open the log file for writing to add additional data.

Is this correct?

xujunmao 04-10-2012 01:13 AM

how to stop logging accurately??
 
1 Attachment(s)
Hi Todd,

thanks for your reply!

The attachment is my script, we need to record the complete log files for each product.But, in fact, the results of the record is not we desired

rtb 04-10-2012 09:15 AM

Hi xujunmao,

Thanks for the script. If I understand correctly, the remote device is sending data, and SecureCRT is not capturing all of the data in the log file.

The remote sends the data in OK.txt, but SecureCRT logs data in NG.txt.

Is this correct?

If not, please explain in more detail what is happening, and what you would like to happen.

What version of SecureCRT are you using?

xujunmao 04-10-2012 09:20 PM

Yes, you correctly understand what I mean.

my SecureCRT's version is "Version 6.6.1 (build 289) - Official Release - November 4, 2010", but In fact, I was used all versions later than 6.6.1,SecureCRT Capture the log results are the same

rtb 04-11-2012 10:56 AM

Hi xujunmao,

Thanks for the confirmation. Now that I know what you want to accomplish, would you post the script you are using that doesn't function correctly?

The original code that you posted does not in any way match the two scripts in the zipped file attachment.

Would you be able to post the actual code that you are using?

Specifically, the code you posted makes a call to WriteLog() with two arguments, and the function script included in the zipped file requires 10 arguments.

xujunmao 04-11-2012 08:44 PM

1 Attachment(s)
Hi Todd,

two scripts use WriteLog() is differently,but the SecureCRT Capture the log results are not correctly in the same.

rtb 04-12-2012 03:39 PM

Hi xujunmao,

Thanks for posting the actual script.

In the script you send multiple strings to the remote in a row without waiting to determine if the remote is ready. Even though you are sleeping, you can't be sure that this will be successful. It would be advisable to follow each Send() with a WaitForString().

With that said, one of the logging problems could be on line 240. Would you post a raw log file that reflects an instance where you manually perform the steps reflected in the OK.txt file?

Here is how you can create a raw log:
  1. Before sending any commands, select Raw Log Session from SecureCRT's File menu.
  2. In the Select Log File dialog, choose a folder and filename in which you would like the log text to be stored and click the Save button. At this point, if you open the File menu, you will notice that Raw Log Session now has a check-mark next to it; this indicates that raw logging is activated.
  3. Now perform the necessary steps on the remote machine.
  4. Select Raw Log Session from the File menu to turn off the raw log feature.

xujunmao 04-15-2012 09:05 PM

2 Attachment(s)
Hi Todd,

The attachment is performed manually generated log files and true information of the remote machine, the log file is missing the last line of data,So I think that follow each Send() with a WaitForString()
is invalid,Do you think ?

ps:there have another script, used by the WaitForString(), but logging is missing the last line yet.

rtb 04-16-2012 11:35 AM

Hi xujunmao,

Thanks for the files. If the file named "actual_102900000003S12411S0018P--10-31-51.log" is a raw log, then you can likely resolve the issue by enabling raw logging in your script.

Can you confirm that "actual_102900000003S12411S0018P--10-31-51.log" is a raw log created in SecureCRT?

To enable raw logging in your script, you can enable a Boolean parameter. Here is the information for the Log() method in the help file:
PHP Code:

object.Log(start[, append[, raw]] 

If you were to add this to your script, you could use the following:
PHP Code:

crt.Session.Log(TrueTrueTrue

This will enable logging, append the log to an existing file and enable raw logging.

By way of explanation, currently, SecureCRT only logs data when a carriage return is received. When using raw logging, all data is logged. It appears as though the remote device is not sending a carriage return after the line you want to log, so SecureCRT is not logging it.

With regards to your question, I don't think that following Send() with WaitForString() will solve this issue, but it is a best practice.

xujunmao 04-19-2012 09:54 PM

1 Attachment(s)
Hi Todd,

Thanks for your answer, it is working like a dream now. I seriously can't thank you enough.

I have another problem: my script need to use the TAB object, but how to use the GET method of the Screen object 'in a TAB object, in my script, TAB object other than the first, using the Screen object 'CurrentRow property captured first TAB objects of the Screen. CurrentRow,why?For details, refer to the attached script

rtb 04-20-2012 10:01 AM

Hi xujunmao,

Thanks for the update. I am glad to hear that raw logging resolved the issue.

With regards to interacting with tabs, you will need to use the tab object for all commands that interact with the tab.

On line 9 you get a handle to a particular tab. The object you use is crt_object. If you want to use the Screen object on this tab, you will need to use the tab object you created. If you use the crt object, the script tab will be referenced rather than the active tab.

On line 193, you use crt.Screen.Get(...). This will access the script tab rather than the active tab. To access the active tab, you will need to use crt_object.Screen.Get(...).

This is the same for functions.

Does this help you resolve the issue?

xujunmao 04-23-2012 01:18 AM

yes, thanks~~!

rtb 04-23-2012 08:18 AM

Thanks for the confirmation xujunmao.

I am glad to know that your script is now functioning as you expect. Please let us know if any other questions or issues arise as you continue scripting.


All times are GMT -6. The time now is 05:38 AM.