0

I need to teach a non-technical person how to configure and run a series of shell scripts. This person has never used the Terminal before.

The shell scripts look something like this:

configOption1 = "abcdefg"
configOption2 = "hijklmnop"

# Do not edit below this line

# ----------------------------

[shell stuff here which runs some `curl` commands to change things on a website]

I could theoretically try to teach her how to make these changes in TextEdit, run chmod +x in the Terminal, and then execute the script, but this would require navigating files and directories in the Terminal, for the chmod +x step if nothing else.

I could maybe also create some type of make-executable.command script that sets chmod +x on the other scripts, but this feels fragile; I want her to be relatively self-sufficient.

Is there an app that would make running the scripts easier for someone without command line experience? The app that most comes to mind is CodeRunner, which I use myself, but it's relatively expensive at $20. It would be nice if there was something free.

7
  • How does the script get created in the first place, how does it get onto the Mac of the user?
    – nohillside
    Commented Feb 21 at 15:10
  • I created the script. I can email them, airdrop them, put them on a USB drive, etc—I haven't really thought about it, it doesn't really matter. Commented Feb 21 at 15:10
  • 1
    It does, as depending on the distribution mechanism, the x bit will already be set. You could even send us a tar.gz for them to double-click
    – nohillside
    Commented Feb 21 at 15:12
  • See also How to make a Mac OS X .app with a shell script? Commented Feb 21 at 17:21
  • Why don't you use arguments passed to your shell scripts so as to avoid any need to edit them and thus any error?
    – athena
    Commented Feb 21 at 18:04

4 Answers 4

1

You can run Shell Scripts directly from the free version of BBEdit.

https://www.barebones.com/products/bbedit/comparison.html

0

.command

A simple approach would be to distribute the shell script with the file extension .command.

When a .command file is opened on macOS, Terminal.app will launch and the script will be executed.

The file may need to be marked executable. If so, distribute the file as a zip or within a disk image.

2
  • Doesn't it need to be marked as an executable after each change? I usually have to, anyway. I don't know a GUI way to do that. Commented Feb 21 at 15:34
  • 1
    This is a good suggestion - and have the terminal Prompt for the text options, depending on how complex the text options are.
    – Demis
    Commented Feb 21 at 16:24
0

Automator

Although I think for you purposes, Applescript is the better option (see above),

Automator also gives easy access to pre-made GUI functions in many apps. You can insert AppleScripts to run Shell scripts using variables acquired by GUI popups (or file paths to the selected files, for example).

For example: Screenshot of Automator action using variables

However it's a bit clunky for using many variables, which is why I suggest Applescript for the GUI directly if you don't mind learning a bit more AppleScripting. But if interacting with apps, such as files in finder, MS or other apps, Automator is pretty fast and straightforward.

0

AppleScript

The shell script can be wrapped up in a do shell script AppleScript command. The resulting AppleScript can then either be distributed as text only .applescript file, or as a complete code signed application.

See /Applications/Utilities/Script Editor.app's options for saving in different formats.

User Interface

Instead of, or in addition to shell script variables, an AppleScript can present a basic user interface.

Apple's Mac Automation Scripting Guide is the canonical guide for AppleScript, which includes a section on Interacting with Users.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .