header image
Overwrite Console Output with printf
September 16th, 2010 under Programming. [ Comments: none ]

for(int i = 0; i < 100; i++) { printf("%d", i); } prints the numers 0-99 behind each other. So 0123456.... However, we would like to see only one number and the previous number is overwritten. We can achieve this by returning the carriage back to the beginning of the current line. This can be done with \r. Thus for(int i = 0; i < 100; i++) { printf("%d\r", i); }


eth0 eth1, NIC naming changes
September 2nd, 2010 under Linux. [ Comments: none ]

With Linux the naming of the NIC’s isn’t fixed. So it might be that it changes after every reboot.

With udev rules  one can fix the naming based on the MAC address of the NICs.

With ArchLinux simple add a file exp 10-network.rules containing text as follows

1
2
3
4
<br />
SUBSYSTEM=="net", ATTR{address}=="00:30:4f:1c:ec:5f", NAME="eth0"<br />
SUBSYSTEM=="net", ATTR{address}=="00:30:48:9c:63:26", NAME="eth1"<br />
SUBSYSTEM=="net", ATTR{address}=="00:30:4e:9c:21:17", NAME="eth2"<br />
<br />
SUBSYSTEM=="net", ATTR{address}=="00:30:4f:1c:ec:5f", NAME="eth0"<br />
SUBSYSTEM=="net", ATTR{address}=="00:30:48:9c:63:26", NAME="eth1"<br />
SUBSYSTEM=="net", ATTR{address}=="00:30:4e:9c:21:17", NAME="eth2"<br />

to the /etc/udev/rules.d directory.

IMPORTANT: Make sure the letters in the MAC address are lower case.