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 ’
’ in this LogError-row.)

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

So RemoteClipboard:

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

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'

Try this:


// put clipboard content in variable
put remoteClipboard() into text
// split clipboard items into discrete lines using "
" as delimiter
split text by "
"

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). :expressionless:

Maybe the the split is not working because the "
" 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 "
" as delimiter 
split text by "
"
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! :smiley:
Or is this not a good solution, what do you mean?

Thank you!

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 "
" 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 "
" 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. :slight_smile:

Aha, i understand. This is a great and easy solution!
That easy, i can’t believe it! :oops:

:smiley:

Big Thank you to you two!