Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-22-2016, 10:07 AM
Tekky Tekky is offline
Registered User
 
Join Date: Apr 2016
Posts: 9
Screen.ReadString Question

I am building off one of your sample python scripts:

ReadDataFromHostFile-SendCommandsFromCommandsFile-LogResultsToIndividualFiles.py

What I am noticing is the data in the saved files are double spaced. It appears the end of each line contains a CR, followed by CRLF.

I don't see a way disable the extra CR.

Is it the Screen.ReadString which is inserting it, or could it possibly be the objLogFile.write?

Would appreciate your input on how to resolve this.

Thanks!
Tek
Reply With Quote
  #2  
Old 04-22-2016, 12:30 PM
Tekky Tekky is offline
Registered User
 
Join Date: Apr 2016
Posts: 9
Attached is a sample screenshot of what I mean.
Attached Images
File Type: jpg screenshot.JPG (40.6 KB, 270 views)
Reply With Quote
  #3  
Old 04-22-2016, 12:51 PM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 811
Hi Tekky.

It sounds like you are actually receiving the CR CRLF at the
end of every line from the remote. One thing you could do
would be to wait for the CR CRLF to appear and change it to
just a CRLF.

Does that work for you?

JJH
Reply With Quote
  #4  
Old 04-25-2016, 05:46 AM
Tekky Tekky is offline
Registered User
 
Join Date: Apr 2016
Posts: 9
Couple things.

1. I do not see the double CR on screen, it's only present in the saved file. If you are able to, could you test the script to see what your results are? I listed the name of the SecureCRT sample script I am building off of.

2. How do I do the conversion to change CR CRLF to appear and change it to
just a CRLF? To me it looks like the Screen.ReadString object saves the contents to a string, and is not saved to a file line by line... If it were line by line, I could strip off the extra CR...

Thanks!
Tek
Reply With Quote
  #5  
Old 04-25-2016, 05:44 PM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 811
Hi Tekky.

The CR just puts the cursor at the beginning of the line.
Multiple CRs won't really look like anything because the
first one will put the cursor at the beginning of the line,
then the subsequent ones will do it again. The LF will take
it to the next line down.

It's up to the editor to decide what it is going to do with
a CR. In your case it sounds like it is treating a CR the
same way it treats a CRLF.

I think the way you would deal with this in a Python script
is after you read the string in, use something like the
following:

strResults = strResults.Replace("\r\r\n","\r\n")

Does that do what you need it to do?

Thanks

JJH
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 02:44 PM.