Mac address as Wifi SSID

Hello,
I want to set MAC ID as SSID, Preferably without ":"
set wireless.ap.ssid= 'Mac ID without ":"'

Please help.

How many devices do you have? I mean if not too many, it could just be easier to type it in.

1 Like

I understand you . I am looking that ass a part of one generic image so i can give it to my friends. and dont need to build every time. Just keep image safe and that's all. I am doing manual at this moment.

Retrieve mac address without ":" from first wireless interface:
cat /sys/class/net/wlan*/address | head -n 1 | tr -d ":"

For your example it should look like:
set wireless.ap.ssid=$(cat /sys/class/net/wlan*/address | head -n 1 | tr -d ":")

1 Like

Thanks ,
what you gave works on cmd. But it looks like SSID has some problem may be limited size. How do I modify this to get last 4 or 5 last characters. So that I can adjust size and try again.

It´s probably related to new line in the cmd output... Try the suggestion below with removing new line...

cat /sys/class/net/wlan*/address | head -n 1 | tr -d ':' | tr -d '\n' | tail -c 4

  • head -n 1 -> take only first line
  • tr -d ':' -> delete all ":"
  • tr -d '\n' -> delete all new lines
  • tail -c 4 -> take only last 4 characters
1 Like

I had same doubt.I thought there might be some invisible character. So I tries to use it as a password, and it worked perfect.

But I am going to try what you said.

Thanks.

WOW, Great, It worked.

this is removing "0" "zero" if it leads. eg. if the four digits are "0be4" , It displays only "be4"

Are you sure? This piped commands are doing only string manipulation and no interpretation as numbers, so leading zeros shouldn't be removed by any of this cmds.
Keep in mind that all non printable characters like newline are also counted.

2 Likes

I think so. Correct me If I am wrong.I used exactly this
$(cat /sys/class/net/wlan*/address | head -n 1 | tr -d ":" | tail -c 4| tr -d "\n")

let me try with 5 instead of 4. that should give clear understanding.

Ahhh.... I made mistake, It should have been this
$(cat /sys/class/net/wlan*/address | head -n 1 | tr -d ":" | tr -d "\n"| tail -c 4)
It should remove any carriage return or invisible character before it works on the string.

Thanks a ton.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.