Running a multiline shell command

Bernard Devlin bdrunrev at gmail.com
Tue Dec 13 07:00:14 EST 2011


How about if you set the shellCommand so that instead of pointing to
"/bin/sh" it points to "/bin/tcsh", or even have the shellCommand set to
point to "/usr/bin/telnet" itself.

There are definitely some oddities with OS X and line endings (I seem to
remember Mark Schonewille explaining it to me some years back (you can see
the oddity by writing out a file in LC with "CR"s at the end of the line,
then using "more" in the shell to list the file back (it will have ^M at
the end of the lines if I remember correctly).

I would imagine that you need to have the same numToChar() characters at
the end of your script as would be expected on the device into which you
are telnetting.

You could also look at using the HEREDOC technique (the code between <<EOF
... EOF, in the first example listed here):

http://www.daniweb.com/software-development/shell-scripting/threads/131047

Bernard

On Mon, Dec 12, 2011 at 11:14 PM, Bob Sneidar <bobs at twft.com> wrote:

> I may have figured a *hack* way around this, at least when doing a
> redirected output to a file:
>
>    repeat with i = 1 to 10
>        put the detailed files into theFileList
>        filter theFileList with "*scanout.txt*"
>        if theFileList is empty then
>            wait one second with messages
>            next repeat
>        end if
>
>
>        if theFileList = theOldFileList then
>            exit repeat
>        end if
>
>        put theFileList into theOldFileList
>        wait one second with messages
>        put i & return & theFileList & return & theOldFileList
>    end repeat
>
> What this does is:
> 1) Gets the detailed files of the folder I am redirecting the file to
> 2) Filters the file list for the file I am redirecting to
> 3) Compares the detailed info to the last time I went through the loop (it
> should change constantly until it's done)
> 4) Bails out when the detailed file info equals the last time through the
> loop.
>
> It's ugly but it works a peach. For anyone else trying something like this
> and doesn't want to work with open process, this may be a good way for them
> to hack around the issue. I tried doing another redirect *after* the first
> one, but the applescript commands are asynchronous, meaning they do not
> stop and wait for a result, at least unless you tell them to, and the
> terminal is not returning anything to Applescript to indicate that it is
> finished with the last command.
>
> Bob
>
>
>



More information about the Use-livecode mailing list