Skip to main content
Jamf Nation, hosted by Jamf, is a knowledgeable community of Apple-focused admins and Jamf users. Join us in person at the ninth annual Jamf Nation User Conference (JNUC) this November for three days of learning, laughter and IT love.

Bash script policy

Here is a script that will allow you to put any bash command in the script's arguments of a policy. Not sure if this should go somewhere else, I'm not really active on the forums so I don't know. I just thought I'd offer it. I label "Parameters 4-11" as "bash command (%MOUNT %COMP %USER)".

#!/usr/bin/perl -w

use strict;

# %MOUNT %COMP %USER are replaced with $ARGV[0], $ARGV[1], $ARGV[2] respectively.

my ( $mount_point, $computer_name, $username ) = splice(@ARGV,0,3);
my $exit = 0;
my $debug = 0;

for my $arg ( @ARGV ) {
    if ( $arg ne '' and $arg !~ /^#/ ) {
        $arg =~ s/%MOUNT/$mount_point/;
        $arg =~ s/%COMP/$computer_name/;
        $arg =~ s/%USER/$username/;
        print "$arg\n" if $debug;
        $exit += 1 if system $arg;
    }
}
exit $exit;
Like Comment