Subject: | |
From: | |
Reply To: | |
Date: | Sat, 23 Sep 2006 10:54:50 +0900 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
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
|
|
|