Skip to main content
Question

Write Hostname into a file during policy execution

  • October 6, 2014
  • 1 reply
  • 0 views

tobiaslinder
Forum|alt.badge.img+16

Hi
We have problems deploying a network profile because of a defect in the way Casper Suite handles Wired 802.1x Network Profiles.

Now we would like to copy and install the profile on the machines with a Policy. The steps are

  1. Install the profile in /tmp
  2. Run a command that replaces a placeholder with the correct hostname of the machine in the profile needed for the connection
  3. Install the profile

I tried this command:

#!/bin/sh

hostname="$2"

sed -i.backup -e 's/hostname-to-be-replaced/$hostname/' /private/tmp/Wired and Wireless.mobileconfig
# /usr/bin/profiles -I -F /tmp/Wired and Wireless.mobileconfig

But somehow the $2 Variable for the hostname is not recognized. It just writes "$hostname" into the file where the placeholder "hostname-to-be-replaced" was. Any Idea how the correct syntax should be here?

Thanks for your help!

1 reply

tobiaslinder
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • 101 replies
  • October 6, 2014

Just figured it out by myself :-). Like this ist works

hostname="$2"

sed -i.backup -e "s/hostname-to-be-replaced/$hostname/" /private/tmp/Wired and Wireless.mobileconfig
# /usr/bin/profiles -I -F /tmp/UEFA Wired and Wireless.mobileconfig

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings