Script Check - Receiving Script exit code: 1 and Unsure?

rgranholm
Contributor

Hi All,

I'm not much of a scripter, but I've put together a script for dockutil and ensured it's installed on all my machines. I'm running this script that seems to be giving me a failure, however, when inspected, it appears to have done everything, can anyone tell me what "Script exit code 1" means and after looking at the code what it would mean that it found no matching processes?

I'd like to get these successful so I'm not left wondering if the install went bad.

Here's the script

#!/bin/bash

user=`ls -l /dev/console | cut -d " " -f 4`

sudo -u $user /usr/local/bin/dockutil --add /Applications/Microsoft Word.app
sudo -u $user /usr/local/bin/dockutil --add /Applications/Microsoft Powerpoint.app
sudo -u $user /usr/local/bin/dockutil --add /Applications/Microsoft Excel.app
sudo killall Dock

Here's the result....

Executing Policy Microsoft Office 365 Volume Installer (applications installation)
Downloading Microsoft Office 2016 Volume Installer.pkg...
Downloading http://jss.insigniam.com/Packages/Microsoft%20Office%202016%20Volume%20Installer.pkg...
Verifying package integrity...
Installing Microsoft Office 2016 Volume Installer [2016-10-28].pkg...
Successfully installed Microsoft Office 2016 Volume Installer [2016-10-28].pkg.
Running script Add Office 365 PP, W, E to Dock...
Script exit code: 1
Script result: No matching processes were found
Error running script: return code was 1

1 ACCEPTED SOLUTION

rgranholm
Contributor

Found reason for it...new version of dockutil....there was an issue in the Sierra dock restart process...will have to push out new dockutil to everyone for pending Sierra update.

View solution in original post

5 REPLIES 5

Look
Valued Contributor III

No need to kill the dock at the end dockutil does this.
use the --no-restart argument on all except the last entry for smoothest effect.
Also I don't think you need to run dockutil as the current user, it does this on it's own with whoever is the front user, although you might want to wait until you are certain a user exists before calling it.

cpdecker
Contributor III

I believe your script exit code: 1 is a result of not finding any processes named "Dock". It may be as @Look says and the process is already terminated. Disclaimer: I have never used dockutil.

CAJensen01
Contributor

Script exit code: 1 means that one of the commands returned an error when attempting to complete.

The error:
Script result: No matching processes were found
Would indicate when you're/have attempted to kill the Dock process, but there wasn't a process running found by that name when the command executed.

If you do encounter a command you want to execute, but want to suppress the result/error, you can send that output to null, using the following syntax, for example:
sudo killall Dock > /dev/null 2>&1
This may not be necessary for your commands here, but might be useful for something else in the future.

rgranholm
Contributor

Thanks for the replies!

So, in my experience, dockutil does not kill the dock after the command is run. See this gif. I am using the latest version of dockutil as of 9/2016 - a majority of my machines are on El Capitan, a few on Sierra

d3d4d89caa2f4e6ca10bbd4ee1525e93

@Look why would i add --no-restart on them? so it's not killing the dock multiple times as it adds these items? I guess that make sense, however, dockutil does not appear to be doing any dock killing, can you confirm?

Also, if a user is not specified, dockutil performs the dock action on all users docks, and that isn't very clean if there are multiple users on the machine. Did you find something counter that in the documentation?

How could the system not find the Dock process, wouldn't that be pretty weird not to be running? It's always running and relaunches the second it's quit.

rgranholm
Contributor

Found reason for it...new version of dockutil....there was an issue in the Sierra dock restart process...will have to push out new dockutil to everyone for pending Sierra update.