Posted on 07-30-2012 08:05 AM
I am trying to run a script based on computer name
This is what I have so far
ComputerName=scutil --get ComputerName
if [[ "ComputerName" = MAC ]]
then
echo""
fi
Posted on 07-30-2012 08:14 AM
First off, what's the purpose of the script? Just to echo the computer name back to you? I'm not sure what ypu're looking to accomplish with it.
Second, you need to do it as ```
if [ "$ComputerName" = "MAC" ]
```in the if/then block (note the $ to indicate its an assigned variable)
Third, if you're running this through a Casper Suite policy, you can also use $2 for the computer name, which Casper assigns automatically. But your scutil command is fine as is.
Posted on 04-05-2013 01:37 PM
@mm2270
Since you were already on this post and you have been quite helpful in the past, I'm hoping you may be able to help.
I'm putting together a similar script/Extension Attribute to check the computer name to see if it has been changed. We use a prefix with the serial number of the computer.
I'm stuck on how to see if the computer name is = to the combined prefix and serial number.
if [[ "$computerName" = "MAC""$SN" ]]
Thanks in advance!
Posted on 04-05-2013 02:05 PM
if [[ "$computerName" = "MAC$SN" ]]
will output MAC1234567890 if 1234567890 was that Mac's serial number.
Posted on 04-05-2013 07:11 PM
Thanks Andrew, I'll give that a try. I could have swore I used that at one point but I was making so many changes who knows.