Re: [DNG] Wifi device names: was systemd is haunting me
On Thu, 11 Feb 2016 12:10:23 +1300 Daniel Reurich wrote: > > How 'legal' do you want this to be? My work contract has a clause > > which states that even if I dream of code/ something else which > > might be useful, the rights rest with my employer. > > That's insane and surely it's legally unenforceable, and certainly if > they don't pay you for the time spent dreaming code > > D: Hi Daniel, You'd be hugely surprised at how literally some states in the US interpret contracts. I live in (anti-employee) Florida, and a friend of mine here in Florida was advised by his lawyer to not work for Linux for the next 6 months because his former employer had a 6 month anti-compete on any Linux work. His lawyer said he'd likely lose the case if he did Linux and his old employer sued. Meanwhile, in California, that kind of non-compete is illegal. This often becomes a problem in Free Software, as former employers covet Free Software rights on software written by their employees on the employee's own time and with the employee's own computer. This is the reason a lot of Free Software authors assign all rights to the FSF. I don't do that because I've been self-employed since 1982. SteveT Steve Litt February 2016 featured book: The Key to Everyday Excellence http://www.troubleshooters.com/key ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
> How 'legal' do you want this to be? My work contract has a clause which > states that even if I dream of code/ something else which might be > useful, the rights rest with my employer. That's insane and surely it's legally unenforceable, and certainly if they don't pay you for the time spent dreaming code D: -- Daniel Reurich Centurion Computer Technology (2005) Ltd. 021 797 722 signature.asc Description: OpenPGP digital signature ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
Steve Litt writes: > Rainer Weikusat wrote: [shell scripts] > At the start of this thread, I had put my contribution into the Public > Domain. Then you and I started incrementally improving it, so it's > pretty much a mashup of both our works. [...] > Is it OK with you to license it Expat? Is it OK with you if both our > names appear on the Copyright line? If so, is the exact correct > spelling of your name "Rainer Weikusat"? How 'legal' do you want this to be? My work contract has a clause which states that even if I dream of code/ something else which might be useful, the rights rest with my employer. OTOH, my employer doesn't care about this and neither do I: If I just post the code without adding something like "this is copyrighted by ... and quoted here for educational purposes", you (or anyone else) can assume "public domain". Spelling is correct. ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
On Mon, 01 Feb 2016 17:08:17 + Rainer Weikusat wrote: > Steve Litt writes: > > On Sun, 31 Jan 2016 18:20:12 -0500 > > Steve Litt wrote: > > [...] > > > === > > #!/bin/sh > > lineno=${1:-1} > > > > fn=`mktemp` > > > > ip -o link | \ > > cut -d ' ' -f2 | \ > > grep ^w | \ > > tr -d : > $fn > > > > maxdev=`wc -l $fn | cut -d ' ' -f 1` > > if test $maxdev -lt $lineno; then > >echo =max$maxdev > > else > > head $fn -n $lineno | \ > > tail -n 1 > > fi > > rm $fn > > === > > [...] > > > There are probably better ways to write this script, but I think the > > way I have it here exhibits the behavior I'd like. > > 'Better' is often very much a matter of opinion but here's one which > doesn't need a temporary file: > > - > #!/bin/sh > want=${1:-1} > got=0 > > for dev in `ip -o link | sed -n 's/[^:]*: *\(w[^:]*\).*/\1/p'`; > do > got=`expr $got + 1` > > test $got -eq $want && { > echo $dev > exit 0 > } > done > > echo =max$got Hi Rainer, At the start of this thread, I had put my contribution into the Public Domain. Then you and I started incrementally improving it, so it's pretty much a mashup of both our works. I'd like to use it in a package of shellscripts I'll be releasing as Free Software. For this particular shellscript written by both of us, would it be OK with you if we licensed it under the Expat license? http://directory.fsf.org/wiki/License:Expat The preceding is basically a dup of the MIT license and some of the later BSD licenses, but by calling it "Expat" we rule out various versions and the like. Is it OK with you to license it Expat? Is it OK with you if both our names appear on the Copyright line? If so, is the exact correct spelling of your name "Rainer Weikusat"? Did anyone else substantially contribute in creating the shellscript to derive the Wifi device name on systems with the new "predictable" device names? If so, same questions to you. Thanks, SteveT Steve Litt February 2016 featured book: The Key to Everyday Excellence http://www.troubleshooters.com/key ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
Steve Litt writes: > On Sun, 31 Jan 2016 18:20:12 -0500 > Steve Litt wrote: [...] > === > #!/bin/sh > lineno=${1:-1} > > fn=`mktemp` > > ip -o link | \ > cut -d ' ' -f2 | \ > grep ^w | \ > tr -d : > $fn > > maxdev=`wc -l $fn | cut -d ' ' -f 1` > if test $maxdev -lt $lineno; then >echo =max$maxdev > else > head $fn -n $lineno | \ > tail -n 1 > fi > rm $fn > === [...] > There are probably better ways to write this script, but I think the > way I have it here exhibits the behavior I'd like. 'Better' is often very much a matter of opinion but here's one which doesn't need a temporary file: - #!/bin/sh want=${1:-1} got=0 for dev in `ip -o link | sed -n 's/[^:]*: *\(w[^:]*\).*/\1/p'`; do got=`expr $got + 1` test $got -eq $want && { echo $dev exit 0 } done echo =max$got ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
On Sun, 31 Jan 2016 18:20:12 -0500 Steve Litt wrote: > Mine has an unintended bug that no matter how high the argument, > it prints the "last" one, where as yours prints nothing if the > argument is higher. I think my unintended bug might be considered > beneficial, although even better would be that if it's too high to > return the number of the last wifi device. I wrote such a script, using Rainer's superior way to determine $lineno and Rainer's tr -d: === #!/bin/sh lineno=${1:-1} fn=`mktemp` ip -o link | \ cut -d ' ' -f2 | \ grep ^w | \ tr -d : > $fn maxdev=`wc -l $fn | cut -d ' ' -f 1` if test $maxdev -lt $lineno; then echo =max$maxdev else head $fn -n $lineno | \ tail -n 1 fi rm $fn === When there's no argument, it delivers the first wifi device. With an argument greater than 0 and less than or equal to the number of wifi devices, it delivers the wifi device corresponding to the number. When the argument is a number higher than the number of wifi devices, it returns a string in the firm of "=max3", if there are 3 wifi devices. If there were only 2 wifi devices, it would have returned "=max2". There are probably better ways to write this script, but I think the way I have it here exhibits the behavior I'd like. SteveT Steve Litt January 2016 featured book: Twenty Eight Tales of Troubleshooting http://www.troubleshooters.com/28 ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
On Sun, 31 Jan 2016 16:56:37 + Rainer Weikusat wrote: > Steve Litt writes: > > [...] > > > > > > #!/bin/sh > > if test "$#" == "0"; then > > lineno="1" > > else > > lineno=$1 > > fi > > > > ip link | \ > > cut -d ' ' -f2 | \ > > grep ^w | \ > > sed -e "s/:\s*$//" | \ > > head -n $lineno | \ > > tail -n 1 > > > > > > The ip command has an -o flag for generating output which is more > easily parseable by program (-o means 'oneline'). This means the same > can be accomplished with > > > #!/bin/sh > lineno=${1:-1} > ip -o link | awk "\$2 ~ /^w/{ if (++nr == $lineno) print > gensub(\":\", \"\", 1, \$2) }" > > awk is generally the easiest to use tool if records made up of lines > are supposed to be split into whitespace-separated fields. The code > can be simplified somewhat by not using the awk gensub function to > get rid of the trailing : but the tr command in 'delete characters' > mode. > > > #!/bin/sh > lineno=${1:-1} > ip -o link | \ > awk "\$2 ~ /^w/{ if (++nr == $lineno) print \$2 }" | \ > tr -d : Nice! The lineno=${1:-1} is a huge improvement over my brute force 5 line if statement. Your version with tr is much more understandable than your one with gensub: As a matter of fact, I wouldn't use the one with gensub on the grounds that it's too complicated for someone not familiar with awk on a programming level. I'm debating whether to cut | grep | sed | head | tail with your awk | tr. Mine has an unintended bug that no matter how high the argument, it prints the "last" one, where as yours prints nothing if the argument is higher. I think my unintended bug might be considered beneficial, although even better would be that if it's too high to return the number of the last wifi device. Thanks, SteveT Steve Litt January 2016 featured book: Twenty Eight Tales of Troubleshooting http://www.troubleshooters.com/28 ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
On Sun, 31 Jan 2016 15:30:01 +0100 Didier Kryn wrote: > Le 31/01/2016 03:12, Steve Litt a écrit : > > #!/bin/sh > > if test "$#" == "0"; then > >lineno="1" > > else > >lineno=$1 > > fi [snip] > Doesn't work out of the box. > > If /usr/bin/test was invoqued you should write '-eq' instead of > '=='. IIRC -eq is for numbers only, not strings. I put doublequotes around each side of the == to make sure it's a string comparison. I consistently do that unless there's a reason I actually want numbers to add and subtract from. > But shell languages have non-standard built-ins. If /bin/sh > points to dash, like in Debian, then the built-in test would accept > '='. I guess '==' is a bashism (actually the adoption of a Cism by a > shell language). Replacing '==' by '=' just works. Confirmed! I replaced the == by =, and it worked perfectly. SteveT Steve Litt January 2016 featured book: Twenty Eight Tales of Troubleshooting http://www.troubleshooters.com/28 ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
Steve Litt writes: [...] > > #!/bin/sh > if test "$#" == "0"; then > lineno="1" > else > lineno=$1 > fi > > ip link | \ > cut -d ' ' -f2 | \ > grep ^w | \ > sed -e "s/:\s*$//" | \ > head -n $lineno | \ > tail -n 1 > > The ip command has an -o flag for generating output which is more easily parseable by program (-o means 'oneline'). This means the same can be accomplished with #!/bin/sh lineno=${1:-1} ip -o link | awk "\$2 ~ /^w/{ if (++nr == $lineno) print gensub(\":\", \"\", 1, \$2) }" awk is generally the easiest to use tool if records made up of lines are supposed to be split into whitespace-separated fields. The code can be simplified somewhat by not using the awk gensub function to get rid of the trailing : but the tr command in 'delete characters' mode. #!/bin/sh lineno=${1:-1} ip -o link | awk "\$2 ~ /^w/{ if (++nr == $lineno) print \$2 }" | tr -d : ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Wifi device names: was systemd is haunting me
Le 31/01/2016 03:12, Steve Litt a écrit : #!/bin/sh if test "$#" == "0"; then lineno="1" else lineno=$1 fi ip link | \ cut -d ' ' -f2 | \ grep ^w | \ sed -e "s/:\s*$//" | \ head -n $lineno | \ tail -n 1 Doesn't work out of the box. If /usr/bin/test was invoqued you should write '-eq' instead of '=='. But shell languages have non-standard built-ins. If /bin/sh points to dash, like in Debian, then the built-in test would accept '='. I guess '==' is a bashism (actually the adoption of a Cism by a shell language). Replacing '==' by '=' just works. Thanks for the script nevertheless :-) Didier ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
[DNG] Wifi device names: was systemd is haunting me
On Sat, 30 Jan 2016 19:26:48 -0500 Haines Brown wrote: > I have been running Debian Sid on a laptop with a purged systemd for > quite a few months. Maybe when I now ran # aptitude update or > safe-upgrade for the first time after several months since the Sid > installation systemd-udevd seems to have switched my wireless > interface from wlan0 to wlp3s0. I hereby donate the following shellscript to the public domain: #!/bin/sh if test "$#" == "0"; then lineno="1" else lineno=$1 fi ip link | \ cut -d ' ' -f2 | \ grep ^w | \ sed -e "s/:\s*$//" | \ head -n $lineno | \ tail -n 1 After naming the preceding shellscript get_wifi_dev.sh, I ran it an ip command diagnostic and get_wifi_dev.sh, and here is what happened: [slitt@mydesk ~]$ ip link | cut -d ' ' -f1-3 | grep "^\S" 1: lo: 2: enp3s0: 3: wlp0s18f2u5: [slitt@mydesk ~]$ mydev=`get_wifi_dev.sh` [slitt@mydesk ~]$ echo $mydev wlp0s18f2u5 [slitt@mydesk ~]$ If you suspect you have more than one wifi device, you can specify which one with a numeric argument to get_wifi_dev.sh, where 1 gets you the first wifi device reported by ip link, 2 gets the second, and so on. If your argument is greater than the number of wifi devices, it just reports the last one reported by ip link. So regardless of how crazy your wifi device naming gets, you can put your device's name in a simple and memorable environment variable. SteveT Steve Litt January 2016 featured book: Twenty Eight Tales of Troubleshooting http://www.troubleshooters.com/28 ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng