Re: Computer name script
Re: Computer name script
- Subject: Re: Computer name script
- From: Nigel Garvey <email@hidden>
- Date: Fri, 06 Jul 2018 13:14:07 +0100
"LaMantia, Brian" wrote on Wed, 04 Jul 2018 19:20:47 +0000:
>Hi all. My script is partially working. It will change the laptop
computer
>name in the format I want. Last 7 characters of the serial number + ML
at
>the beginning. The desktops do not work at all and I can’t figure out
why.
>Any thoughts? Thank you.
>
>#!/bin/bash
>
>serial=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk
>'/Serial\ Number\ \(system\)/ {print substr($0,length-6)}')
>IS_Laptop="$(/usr/sbin/system_profiler SPHardwareDataType | grep "Model
>Identifier" | grep "Book")"
>laptop='ML'
>desktop='MD'
>
>if [ "$IS_LAPTOP" != "" ]; then
>scutil --set LocalHostName "$desktop$serial"
>scutil --set ComputerName "$desktop$serial"
>scutil --set HostName "$desktop$serial"
>else
>scutil --set LocalHostName "$laptop$serial"
>scutil --set ComputerName "$laptop$serial"
>scutil --set HostName "$laptop$serial"
>fi
I _think_ it's because IS_LAPTOP is a difference case from IS_Laptop, so
it's not the same variable and "$IS_LAPTOP" is always "" .
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden