LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-18-2012, 06:38 PM   #1
zithro
Member
 
Registered: Aug 2012
Distribution: Slackware 13.37
Posts: 46

Rep: Reputation: Disabled
rc.wireless tr error ?


Hello,

I just installed Slack 13.37 on my laptop. Happy me

When reading the boot log, I realized there may be a little 'bug' in the rc.wireless file, causing an error 'tr: extra operand [A-F]'.
The buggy command is :
Code:
# Get the MAC address for the interface
HWADDR=`/sbin/ifconfig ${INTERFACE} | sed -ne 's/.*\(..:..:..:..:..:..\).*/\1/p' | tr [a-f] [A-F]`
Its not really a bug as nothing is impacted, but yet, I get this error message. When executing this command in bash though, no error is reported, i get my MAC uppercased.

So I read the tr man, then the "info coreutils 'tr invocation'", and here's what I read:
Quote:
GNU `tr' does not support the System V syntax that uses square brackets to enclose ranges. Translations specified in that format sometimes work as expected, since the brackets are often transliterated to themselves. However, they should be avoided because they sometimes behave unexpectedly. For example, `tr -d '[0-9]'' deletes brackets as well as digits.
I have two questions:
- shouldn't the brackets be removed from the command in rc.wireless ? Even going further, shouldn't the command be tr abcdef ABCDEF ?
- why is this command interpreted differently at boot time and in bash ?
- am I being a bee f***er ? (sorry, french literal translation for 'being too finicky')

Thanks

Last edited by zithro; 08-19-2012 at 06:45 AM. Reason: Starred the f word
 
Old 08-19-2012, 04:59 AM   #2
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Quote:
Originally Posted by zithro View Post
I have two questions:
- shouldn't the brackets be removed from the command in rc.wireless ? Even going further, shouldn't the command be tr abcdef ABCDEF ?
- why is this command interpreted differently at boot time and in bash ?
- am I being a bee f****r ? (sorry, french literal translation for 'being too finicky')
That's 3 questions... but

Yes, they should.

I'm not sure (but the [ and ] will be treated as literals which explains why it still looks like it works when you run it manually),

And no you're not, though use of the f word is undesirable here on LQ.


As it happens, the tr can be avoided completely as sed can be asked to do the upper-case conversion by adding a "\U"
Code:
/sbin/ifconfig ${INTERFACE} | sed -ne 's/.*\(..:..:..:..:..:..\).*/\U\1/p'

P.S. Good spot though.

Last edited by GazL; 08-19-2012 at 05:23 AM.
 
Old 08-19-2012, 07:03 AM   #3
zithro
Member
 
Registered: Aug 2012
Distribution: Slackware 13.37
Posts: 46

Original Poster
Rep: Reputation: Disabled
Yeah 3 questions, but the 3rd was more rhetorical. Starred the f word though

Ok for the difference between boot/bash. Can commands inputs/outputs be interpreted differently depending on the shell one's using ?
And btw, what's the shell used at boot time, sh ? Or it's not really a shell ?

Thanks for your answers, and the sed switch, gonna edit my file.
Maybe slack14 will incorporate your changes.

Last edited by zithro; 08-19-2012 at 07:03 AM. Reason: typo
 
Old 08-19-2012, 07:59 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
The shell being used should be bash, but invoked as /bin/sh which does change some of it's behaviour. But even so, I don't understand what was upsetting tr on your system as the error should have been harmless. Most odd.
 
Old 08-19-2012, 09:19 AM   #5
zithro
Member
 
Registered: Aug 2012
Distribution: Slackware 13.37
Posts: 46

Original Poster
Rep: Reputation: Disabled
Ok, i created a test user with the /bin/sh shell instead of /bin/bash, and the command is showing the error.
So 'tr' parameters are not interpreted the same way in bash and sh.
Thanks for pointing that out to me !

PS : the error was in fact harmless, as my wireless card was properly working. The HWADDR var is even not needed for my setup, as im not using the rc.wireless.conf file. Can as well comment the line.
I was just trying to understand & suppress the error message (dont like them).

From a newbie perspective, the wpa_supplicant integration is not as clear as the rc.* scripts are.
I wish the whole WPA thing could be configured from ONLY the rc.wireless/rc.wireless.conf files (so without a wpa_supplicant.conf file). From what I read and understood in AlienBOB's WPA guide, it's not possible. But me noob, so maybe I wasn't getting the whole point. Now I messed a bit more with the files, I'm gonna re-read this guide.

But now I think about it, I read in slack14 changelog (search for "rc.wireless" in http://slackware.com/changelog/current.php?cpu=i386 ):
Quote:
Perhaps this was the cause of some of the reports of non-functional wireless interfaces?
My 'tr' error MAY be a cause for non-functional wireless devices.
If you use the rc.wireless.conf file for wireless settings, and you dont write them in the generic case ($HWADDR in *), rather in the card-specific blocks ($HWADDR in xx:xx:xx), as the $HWADDR is not set, the script may not find the correct parameters, as never entering any case ?!
My 2 cents.

Last edited by zithro; 08-19-2012 at 09:34 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error after downloading updates, wireless connection gone, error code, help Lucy Linux - Newbie 1 11-15-2011 07:23 PM
CentOS 5.2 wireless problem with Intel 4965 AGN wireless : SIOCGIFFLAGS error: No suc centguy Linux - Wireless Networking 2 08-12-2008 03:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration