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 Terminal Automation
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="xstep" data-source="post: 267043" data-attributes="member: 11647"><p>The cheap & dirty way is to create a shell script and execute it via the Fiinder.</p><p></p><p>Open up Terminal and cut and paste this, then type CONTROL-D to exit.</p><p></p><p>cat >testb2.bash</p><p>#!/bin/bash</p><p>/usr/bin/v2u -a hs=-61</p><p>exit</p><p></p><p>Now type chmod u+x testb2.bash on the command line to make it executable.</p><p>When you first double click on it from the finder, you'll be asked what application to use. So set it to use Terminal.</p><p></p><p>The negative of the method is it opens Terminal and leaves a dead window open.</p><p></p><p></p><p>The cleaner way would seem to be to use Applescript. So I've wondered for some time how to do that and came up with this.</p><p></p><p><strong>--- Cut & Paste from below this line ---</strong></p><p>(*</p><p>Note that the $status value throws an exception to Applescript if not zero and is not returned.</p><p>The "giving up after 2" automatically closses the window after 2 seconds.</p><p>*)</p><p></p><p>do shell script "/bin/bash; /usr/bin/v2u -a hs=-61"</p><p>set myReturnedText to result</p><p>if the myReturnedText is "" then</p><p>display dialog "Script was Successful." buttons {"OK"} giving up after 2 default button 1</p><p>else</p><p>display dialog "Script returned: " & myReturnedText buttons {"OK"} giving up after 2 default button 1</p><p>end if</p><p></p><p><strong>--- Stop Cut & Paste before this line ---</strong></p><p></p><p>The "/bin/bash;" text may not be required.</p><p></p><p>So what do you do with it. While you open up Script Editor in the Applescript folder in the Applications folder. A new project window will open. Copy and paste the above code in and save the project. I saved it in my usernames Library/Scirpts folder.</p><p></p><p>This apple tech note might be a start.</p><p>Technical Note TN2065: do shell script in AppleScript</p><p><a href="http://developer.apple.com/technotes/tn2002/tn2065.html" target="_blank">http://developer.apple.com/technotes/tn2002/tn2065.html</a></p><p></p><p>By the way, my menu bar has a script symbol on the right side. I'm not sure how I got it there, but I think I replied YES to some question the first time I started Script Editor. This makes it easy to find and execute the script.</p></blockquote><p></p>
[QUOTE="xstep, post: 267043, member: 11647"] The cheap & dirty way is to create a shell script and execute it via the Fiinder. Open up Terminal and cut and paste this, then type CONTROL-D to exit. cat >testb2.bash #!/bin/bash /usr/bin/v2u -a hs=-61 exit Now type chmod u+x testb2.bash on the command line to make it executable. When you first double click on it from the finder, you'll be asked what application to use. So set it to use Terminal. The negative of the method is it opens Terminal and leaves a dead window open. The cleaner way would seem to be to use Applescript. So I've wondered for some time how to do that and came up with this. [B]--- Cut & Paste from below this line ---[/B] (* Note that the $status value throws an exception to Applescript if not zero and is not returned. The "giving up after 2" automatically closses the window after 2 seconds. *) do shell script "/bin/bash; /usr/bin/v2u -a hs=-61" set myReturnedText to result if the myReturnedText is "" then display dialog "Script was Successful." buttons {"OK"} giving up after 2 default button 1 else display dialog "Script returned: " & myReturnedText buttons {"OK"} giving up after 2 default button 1 end if [B]--- Stop Cut & Paste before this line ---[/B] The "/bin/bash;" text may not be required. So what do you do with it. While you open up Script Editor in the Applescript folder in the Applications folder. A new project window will open. Copy and paste the above code in and save the project. I saved it in my usernames Library/Scirpts folder. This apple tech note might be a start. Technical Note TN2065: do shell script in AppleScript [url]http://developer.apple.com/technotes/tn2002/tn2065.html[/url] By the way, my menu bar has a script symbol on the right side. I'm not sure how I got it there, but I think I replied YES to some question the first time I started Script Editor. This makes it easy to find and execute the script. [/QUOTE]
Verification
Name this item. 🍎
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Basic Terminal Automation
Top