• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Copy folder shell scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copy folder shell scripting


  • Subject: Re: Copy folder shell scripting
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 24 Apr 2008 09:24:12 -0700

On Apr 24, 2008, at 7:35 AM, Mark J. Reed wrote:

You can put any kind of interpreter name after the #! and it will work,. for instance

#!/usr/bin/osascript
path to me

works (at least on Leopard; a niggling memory is telling me that you
might have to add an option after the /osascript to get it to work on
earlier versions of OS X).

Actually, it just doesn't work in earlier versions. It's possible to fake it, though; here's one way:


#!/bin/sh
osascript - "$@" <<EOF
your script here
EOF

An executable file beginning with "#!something" will execute "something", passing it the name of the original file as its last parameter. Read execve(3) for all the details.

However, the #! line is itself included in the input fed to the interpreter, so this trick won't work if the interpreter is confused.
# is normally a comment to the shell, so that's not a problem, but programs like osascript have to have the ability to handle that line built in.

The #! (pronounced "shebang"; yes, really) line relies on interpreter treating "#" as a comment-to-end-of-line character. It's a common feature of Unix-based languages for this reason. AppleScript prior to Leopard didn't have that; now it does. There's nothing in osascript to handle it; it's built into AppleScript. This was partly for consistency, but more because that way you can write your script in Script Editor with the shebang intact and not worry about it.



--Chris Nebel AppleScript Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Copy folder shell scripting
      • From: Bruce Robertson <email@hidden>
References: 
 >Copy folder shell scripting (From: ba95 <email@hidden>)
 >Re: Copy folder shell scripting (From: "Mark J. Reed" <email@hidden>)
 >Re: Copy folder shell scripting (From: "Mark J. Reed" <email@hidden>)
 >Re: Copy folder shell scripting (From: ba95 <email@hidden>)
 >Re: Copy folder shell scripting (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Frontmost Application Problem
  • Next by Date: the odd case of the disappearing Eudora dictionary
  • Previous by thread: Re: Copy folder shell scripting
  • Next by thread: Re: Copy folder shell scripting
  • Index(es):
    • Date
    • Thread