How to convert complex applescript to single line for terminal

I have a complex AppleScript that for some reason should run as a single line. My Script looks like this:

tell application "Finder"
    tell disk "'myDiskName'"
        open
        set current view of container window to icon view
        set toolbar visible of container window to false
        set statusbar visible of container window to false
        set the bounds of container window to {400, 100, 968, 421}
        close
        open
        eject
    end tell
end tell

I am executing Script using terminal:

echo '<SCRIPT>' | osascript

where the multiline Script is higher - and it works absolutely fine. Now, to be more specific, I want this Script to be run using ant -task, for example:

<exec executable="echo">
    <arg line="'<SCRIPT>' | osascript" />
</exec>

, - / , . : , , applescipt, . : Script , - Script " " .

+3
2

AppleScript Ant build script, script CDATA.

Ant, script exec inputstring:

<project name="AppleScript" default="applescript">

    <macrodef name="applescript">
        <text name="text.script" trim="false" optional="false" />
        <sequential>
            <exec executable="/usr/bin/osascript" inputstring="@{text.script}" />
        </sequential>
    </macrodef>

    <target name="applescript">
        <applescript>
            <![CDATA[
tell application "Finder"
    open startup disk
end tell
            ]]>
        </applescript>
    </target>

</project>
+6

, "ant -task", , ...

/usr/bin/osascript -e "tell application \"Finder\"" -e "tell disk \"'myDiskName'\"" -e "open" -e...

, "-e", , .

+7

Source: https://habr.com/ru/post/1758734/


All Articles