MACSCRPT Archives

September 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 23 Sep 2006 10:54:50 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (53 lines)
Hello,

I have a question about 'echo' in "do shell script" command.

I want to pass a text (which may contain new lines, and any Unicode  
characters) to a shell script, and I tried to use:

	do shell script "echo" & space & quoted form of the_text & space &  
"| perl -e '...' | ..."

BUT I realize that 'echo' takes an argument which ends with a new line.

For example, if I have testfile.txt with the following content:

a
<space>b
c
<space>d
e
<space>f

'cat /tmp/testfile.txt' will output the same text as testfile.txt.  
But 'echo `cat testfile.txt` will return

a b c d e f

But if I write the same text for example in Nisus Writer Express, and  
I do:

tell application "Nisus Writer Express"
	set the_text to selected text of document 1
end tell

do shell script "echo " & quoted form of the_text

I seem to get the right result.  But this seems strange, and perhaps  
not very safe way to put the input data into STDOUT.

Perhaps I may use something like:

do shell script "perl -e '$_ = shift; print'" & space & quoted form  
of the_text & space & "| ..."

??

Thank you in advance for any insight.

Best regards,

Nobumi Iyanaga
Tokyo,
Japan

ATOM RSS1 RSS2