Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Basic AppleScript w/Terminal Question
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Mark FX" data-source="post: 1382618" data-attributes="member: 211556"><p>You simply set the variable to the do shell script command like this.</p><p></p><p>[CODE]</p><p>set myApplications to do shell script "ls /Applications/"</p><p>[/CODE]</p><p></p><p>By default the returned myApplications variable result is a Applescript text type, as UTF-8 format, but you can use different types like this.</p><p></p><p>[CODE]</p><p>set theBinaryData to do shell script ("curl " & quoted form of theURLvariable) as data</p><p>[/CODE]</p><p></p><p>this will return binarydata.</p><p></p><p>If you dont have Administrator privileges, you can use a command like this.</p><p></p><p>[CODE]</p><p>set myApplications to do shell script "ls /Applications/" with administrator privileges ¬</p><p> user name "adminName" password "adminPassword"</p><p>[/CODE]</p><p></p><p>To find out all of the options for the do shell script command, look in the </p><p>StandardAdditions.sdef file, from the Window / Library menu.</p><p></p><p>Also you can script the Terminal Application like this.</p><p></p><p>[CODE]</p><p>tell application "Terminal"</p><p> activate</p><p> do script "ls /Applications/"</p><p>end tell</p><p>[/CODE]</p><p></p><p>In all of the above examples, you can also use echo and pipes in your shell commands.</p><p></p><p>Hope this is of some help</p><p></p><p>Regards Mark</p></blockquote><p></p>
[QUOTE="Mark FX, post: 1382618, member: 211556"] You simply set the variable to the do shell script command like this. [CODE] set myApplications to do shell script "ls /Applications/" [/CODE] By default the returned myApplications variable result is a Applescript text type, as UTF-8 format, but you can use different types like this. [CODE] set theBinaryData to do shell script ("curl " & quoted form of theURLvariable) as data [/CODE] this will return binarydata. If you dont have Administrator privileges, you can use a command like this. [CODE] set myApplications to do shell script "ls /Applications/" with administrator privileges ¬ user name "adminName" password "adminPassword" [/CODE] To find out all of the options for the do shell script command, look in the StandardAdditions.sdef file, from the Window / Library menu. Also you can script the Terminal Application like this. [CODE] tell application "Terminal" activate do script "ls /Applications/" end tell [/CODE] In all of the above examples, you can also use echo and pipes in your shell commands. Hope this is of some help Regards Mark [/QUOTE]
Verification
Name this item. 🍎
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Basic AppleScript w/Terminal Question
Top