Results 1 to 4 of 4
  1. #1
    Voix
    Guest
    Basic Terminal Automation
    I've got a very basic question. I would like to save a repetitive terminal session to something like a batch file in Windows. Here's what I type into terminal every time I launch my video capture device:

    /usr/bin/v2u -a hs=-61

    I'd like to save that as a file that I can just click and be done with it. How do I go about that?

  2. #2
    Basic Terminal Automation
    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    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.

    --- Cut & Paste from below this line ---
    (*
    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

    --- Stop Cut & Paste before this line ---

    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
    http://developer.apple.com/technotes/tn2002/tn2065.html

    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.

  3. #3
    Voix
    Guest
    That worked great. Thank you so much.

  4. #4
    Basic Terminal Automation
    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    Your welcome. Glad to get the feedback that it worked out.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Basic AppleScript w/Terminal Question
    By salgala2000 in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 03-14-2012, 03:30 PM
  2. basic terminal commands not working
    By ent_matt in forum OS X - Operating System
    Replies: 12
    Last Post: 07-28-2011, 02:56 PM
  3. Need some basic terminal commands...
    By maxf in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 07-22-2007, 01:46 AM
  4. Keyboard automation
    By enigmafyv in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 06-09-2007, 08:16 PM
  5. Automation for my TV Shows
    By BushyMark in forum iPod Hardware and Accessories
    Replies: 1
    Last Post: 10-17-2006, 09:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •