From UA Libraries Digital Services Planning and Documentation
Revision as of 16:52, 10 November 2010 by Scpstu32
Cabaniss_Software (For the Cabaniss NHPRC project)
Mass_Content_Software (for mass digitization of collection materials to be linked to from finding aid, without manually-created item level metadata)
On Making Scripts Work on Mac OSX
- To associate files with particular software , CTRL-click on the file.
- Choose "open with". If that isn’t available, choose "open".
- In the Enable box, set the value to "All Applications".
- Check the "Always Open With" box.
- Select Utilities>Terminal
- Then click "Open" and you should be good to go.
- Since the MACs come with many scripting languages pre-installed the scripts are essentially run by double clicking on the file name, although manually launching them from the terminal should work as well.
- For example:
$ python foo.py $ ./foo.py
- In the second case the script AND in the case of double-clicking the filename, the script would have to include the appropriate shebang line, for example #!/usr/bin/python for Python scripts and #!/usr/bin/perl for Perl scripts.
- This will allow the MACs to know where to locate Python and Perl, respectively.
- If for some reason this doesn't work, make sure the script is saved with a UNIX style byte order so that the shebang will be read properly by the MAC.
- A good text editor like Notepad ++ (Windows) easily allows one to make these changes to text files.
- Save scripts with a UNIX style byte order. Not doing so appears to prevent the OS from being able to read the shebang line.
- If you are adding timestamps to log files in strip all whitespaces and colons from your timestamp variable for any timestamps . Not doing so can prevent the file from getting written.
- For example if your timestamp variable is $timestamp in a PERL script try this:
#start MAC block #trimming whitespace and colons because the MAC won't write the output file if they are present $timestamp=~ s/\s//g; $timestamp=~ s/://g; #end MAC block
- Make sure you use only forward slashes for path slashes. e.x. "foo/bar" is good, but "foo\bar" is bad.
- There should be no need to ever use backslashes in scripts, however, as Windows OS is equally tolerant of forward and back slashes.