paste a RemoteClipboard into a Error-Log

i have to copy a text from a remote WindowsXP-SUT and paste this error-messages into our eggplant log.

With
LogError RemoteClipboard ()
this is all right. But in the log are now all lines in one row. (All returns are now '\n' in this LogError-row.)

How could we split this entire clipboard-text by every '\n' in separate LogError lines?

So RemoteClipboard:
RecID 226 in sem_4 - Feld mod_timestamp:  '30.12.1899' <> '05.09.2008 16:01:31'\nRecID 226 in sem_4 - Feld mod_timestamp_semdet:  '29.08.2008 16:58:02' <> '05.09.2008 16:01:31'\nRecID 54 in sem_4 - Feld mod_timestamp:  '30.12.1899' <> '05.09.2008 16:01:28'\nRecID 54 in sem_4 - Feld mod_timestamp_semdet:  '29.08.2008 16:58:02' <> '05.09.2008 16:01:28'\nRecID 218 in sem_4 - Feld mod_timestamp:  '30.12.1899' <> '05.09.2008 16:01:29'\n

show in the eggplant logfile like this:
logerror RecID 226 in sem_4 - Feld mod_timestamp:  '30.12.1899' <> '05.09.2008 16:01:31'
logerror RecID 226 in sem_4 - Feld mod_timestamp_semdet:  '29.08.2008 16:58:02' <> '05.09.2008 16:01:31'
logerror RecID 54 in sem_4 - Feld mod_timestamp:  '30.12.1899' <> '05.09.2008 16:01:28'
logerror RecID 54 in sem_4 - Feld mod_timestamp_semdet:  '29.08.2008 16:58:02' <> '05.09.2008 16:01:28'
logerror RecID 218 in sem_4 - Feld mod_timestamp:  '30.12.1899' <> '05.09.2008 16:01:29'

Comments

  • Try this:
    // put clipboard content in variable
    put remoteClipboard() into text
    // split clipboard items into discrete lines using "\n" as delimiter
    split text by "\n"
    
    repeat with error_text = each item in text
    	LogError error_text
    end repeat
    
  • Thankyou EPJoK!
    Are here maybe an typing error? i have this copied into our code but in the ErrorLog is the same one line (no spliting). :|
  • Maybe the the split is not working because the "\n" are not being interpreted as characters. You might want to try:
    put remoteClipboard() into text
    
    repeat with error_text = each line in text
       LogError error_text
    end repeat
    

    You can also use a different delimiter in the split command.
  • EPJoK, with your hint i have searched this way in the pdf-manual. End there i found this solution:
    put RemoteClipboard() into text
    // split clipboard items into discrete lines using "\n" as delimiter 
    split text by "\n"
    repeat with each line of text
    	LogError it
    end repeat
    

    interestingly this will put an "("-character as first character of the first LogError-line and after the last LogError-line will be an ")"-character.

    It seems that this works! :D
    Or is this not a good solution, what do you mean?

    Thank you!
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    Here's a little explanation that may help you to understand what's happening:

    When you log something containing return characters, Eggplant converts the returns to "\n" characters in the log file to keep it as a single line. This is important because the structure of the log file needs to keep each entry on a single line.

    The value returned by the remoteClipboard() function in your case contains multiple lines, but the return characters separating the lines haven't been converted to "\n" yet, so splitting the text by that value doesn't actually split it up, it just turns it into a list containing one item (the entire text). The parentheses you're seeing are a result of it being a list.

    So, the solution you really want is a bit simpler -- just eliminate the split command, and log each line separately:
    put RemoteClipboard() into text 
    
    repeat with each line of text 
       LogError it 
    end repeat 
    
    I hope that helps clear things up. :)
  • Aha, i understand. This is a great and easy solution!
    That easy, i can't believe it! :oops:


    :D

    Big Thank you to you two!
Sign In or Register to comment.