0

I am creating a shell script to automate our certificate import process. It will be running as root to update group policy. Once complete, how can we change the root to logged in username in MAC?

Ex:

#!/bin/bash
VERSION=1

#Internal network check
 if ping -c 2 source.vmware.com ; then OK ; else echo “Exiting, not connected to internal network” ; fi

sudo gpupdate

Post this we will have to run a command "SCC" which will import the certificate, but it only runs as the logged user (AD username)? Need help...

Ipor Sircer
  • 1,226
  • 7
  • 8
Deepak
  • 1

1 Answers1

2
su -c "your command" username

As in the help:

$ su --help
Usage: su [options] [LOGIN]

Options:
  -c, --command COMMAND         pass COMMAND to the invoked shell
  -h, --help                    display this help message and exit
  -, -l, --login                make the shell a login shell
  -m, -p,
  --preserve-environment        do not reset environment variables, and
                                keep the same shell
  -s, --shell SHELL             use SHELL instead of the default in passwd
the_nuts
  • 430
  • 6
  • 19