User avatar
RDK
Posts: 262
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Editing the Samba Config file

Wed Aug 27, 2014 8:20 am

Folks....I'm well along the way to getting my Pi basic configuration done. I just installed SAMBA and it seems to be working, ie I can see the USB key share I set up.

What I would like to do is create a cleaned up copy of the smb.conf file. It has lots of comments (#'s and ;'s) which make reading it and debugging painful. I found this script on the web:

Code: Select all

grep -ve ^# -ve ‘^;’ -ve ^$ smb.confcopy> smb.confclean
but when I run it in super user mode, the command does not finish, that is it does return to the normal prompt even after 10+ minutes. CTL-c gets me back to the prompt.

What am I doing wrong? OS is RASPBIAN .

Thanks...RDK

User avatar
RaTTuS
Posts: 10500
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Editing the Samba Config file

Wed Aug 27, 2014 8:41 am

are you running sudo blah or
are you doing
sudo sh
then running the command

the second will work the first will not - the redirection will not happen as you think it will
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Editing the Samba Config file

Wed Aug 27, 2014 9:01 am

try this


cat smb.conf | grep -ve ^# -ve \.^\;\. -ve ^$ > outfile
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
jojopi
Posts: 3085
Joined: Tue Oct 11, 2011 8:38 pm

Re: Editing the Samba Config file

Wed Aug 27, 2014 10:55 am

RDK wrote:grep -ve ^# -ve ‘^;’ -ve ^$ smb.confcopy> smb.confclean
In the recipe that you found, there were obviously supposed to be ASCII single quotes around ^; to protect the semicolon from the shell. Something along the way has converted them into Unicode left- and right- single quotes, which no longer serve the purpose. So you have two commands separated by semicolon:

Code: Select all

grep -ve ^# -ve ‘^;
’ -ve ^$ smb.confcopy> smb.confclean
The first grep is reading from standard input, so it waits for you to press Ctrl+D or Ctrl+C. The second "command" is nonsense.

With the correct quotes (and running in a root shell as RaTTuS explains) the command should work (though it is redundant to give the -v option three times).
Richard-TX wrote:cat smb.conf | grep -ve ^# -ve \.^\;\. -ve ^$ > outfile
You have quoted the semicolon adequately, but what are the \. for? The beginning of line (^) cannot match after ., so your version does not remove ; comments.

User avatar
RDK
Posts: 262
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Editing the Samba Config file

Wed Aug 27, 2014 11:12 am

Folks....Thanks, I think I understand the comments. The string posed by Richard-TX worked good enough for me. It did not eliminate the ; lines nor the blank lines, but did get rid of the # line comments. I can live with this reduction.

Perhaps later I will try the other suggestions and try to really understand what they are doing.

Again, thanks....RDK

tekim
Posts: 13
Joined: Fri Sep 28, 2012 7:14 pm
Location: U.K.

Re: Editing the Samba Config file

Sat Aug 30, 2014 1:42 pm

Greetings,

Does the "testparm" command not achieve a similar result?

testparm > smbclean.conf

or maybe

testparm -v > smbclean.conf
for all the default setting included.

Cheers,

Return to “Beginners”