Unless I am smoking crack, I think I have found a problem with using multiple sed shell commands in Applescript.
Whenever I make one sed call, the second one never works.
This has been boggling my mind for a while now.
What appears to be happening is that sed is taking a string where each line is delimited by \r\n and only returning \r as the line delimiter.
As far as I know, I'm not asking sed to do that.
I've tested two sed shell calls in the Script Debugger and in the AS editor in Snow Leopard and this is what I get. The AS editor actually displays the hidden characters properly.
do shell script "sed 's/^ *//'<<<'?SYMBOLS\r\n?HEADING \"RSA57000 - CUSTOM PRICING PRODUCT MAINTENANCE\"\r\n\r\n IDENTIFICATION DIVISION.\r\n\r\n
--> "?SYMBOLS\r?HEADING \"RSA57000 - CUSTOM PRICING PRODUCT MAINTENANCE\"\r\rIDENTIFICATION DIVISION.\r\rPROGRAM
and
do shell script "sed '/^\\*/d'<<< '?SYMBOLS\r\n?HEADING \"RSA57000 - CUSTOM PRICING PRODUCT MAINTENANCE\"\r\n\r\n
--> "?SYMBOLS\r?HEADING \"RSA57000 - CUSTOM PRICING PRODUCT MAINTENANCE\"\r\r IDENTIFICATION DIVISION.\r\r
As we can see, the \r\n, return linefeed characters are being replaced with just \r.
What this means is that your first sed command will work, but the resulting string has its line delimiter pattern changed. From what I have been told, sed requires \r\n as the pattern for determining that a line ends. This means that your second sed call through the shell from AppleScript will always fail, resulting in much confusion.
Any input into this matter in the line of "force sed output called from a shell script in AppleScript to not mess with the linefeeds or force a \r\n pattern" will be greatly appreciated and I will speak well of your ilk to visiting dignitaries from foreign and obscure realms.
TIA, - Alex Zavatone This email message and any attachments are for the sole use of the intended recipient(s) and may contain information that is proprietary to U.S. Foodservice, Inc and/or its subsidiaries or otherwise confidential or legally privileged. If you have received this message in error, please notify the sender by reply, and delete all copies of this message and any attachments. If you are the intended recipient you may use the information contained in this message and any files attached to this message only as authorized by U.S. Foodservice. Files attached to this message may only be transmitted using secure systems and appropriate means of encryption, and must be secured using the same level password and security protection with which the file was provided to you. Any unauthorized use, dissemination or disclosure of this message or it's attachments is strictly prohibited.
|