LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-24-2012, 05:18 PM   #1
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 431
Blog Entries: 32

Rep: Reputation: 3
Customized permission denied error


Hi, I am writing a script that searches for network shares in the same server and maps them to a local folder all at once, but there are some windows share such as $C $D $E that shows up which are not physically mountable, these drives shows as if permission denied, I wish to add customized error if permission denied, how would I modify the sript?
output
Code:
ted:$ sudo /mnt/main/script/netmount.sh
WARNING: The security=share option is deprecated
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.6]
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.6]
mounting....................................	//SERVER/main
WARNING: The security=share option is deprecated
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.6]
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.6]
mounting....................................	//NAS/root
mounting....................................	//NAS/main
mounting....................................	//NAS/downloads
mounting....................................	//NAS/media
mounting....................................	//NAS/stream
WARNING: The security=share option is deprecated
Domain=[TED-PC] OS=[Windows 7 Professional 7600] Server=[Windows 7 Professional 6.1]
mounting....................................	//TED-PC/ADMIN$
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mounting....................................	//TED-PC/C$
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mounting....................................	//TED-PC/D$
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mounting....................................	//TED-PC/Desktop
mounting....................................	//TED-PC/E$
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mounting....................................	//TED-PC/F$
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mounting....................................	//TED-PC/G$
mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mounting....................................	//TED-PC/My Documents
mounting....................................	//TED-PC/print$
script
Code:
ted:$ cat netmount.sh
output="$(nmblookup -S workgroup)"
IFS=" "
outputs=($output)
for each in ${outputs[@]} ; do
	if [ "${each:0:10}" == "192.168.1." ] && [  "${each:0:13}" != "192.168.1.255" ] ; then
		IFS="
		"
		parts=($each) ; ip="${parts[0]}" ; netbios="${parts[1]}"
		if [ ! -e "/mnt/share/$netbios" ] ; then
			mkdir "/mnt/share/$netbios"
		fi
		output1="$(smbclient -N -L //$ip -g)"
		IFS="
"
		dirs=($output1)
		for each1 in ${dirs[@]} ; do
			if [ "${each1:0:4}" == "Disk" ] ; then
				IFS="|"
				dir=($each1)
				if [ ! -e "/mnt/share/$netbios/${dir[1]}" ] ; then
					mkdir "/mnt/share/$netbios/${dir[1]}"
				fi
				if [ -z "$1" ] ; then
					echo "mounting....................................	//$netbios/${dir[1]}"
					mount -t cifs -o username=ted,password= //"$ip"/"${dir[1]}" /mnt/share/"$netbios"/"${dir[1]}"
				else
					echo "umounting.................................	/mnt/share/$netbios/${dir[1]}"
					umount "/mnt/share/$netbios/${dir[1]}"
				fi
				i=$((i+1))
			fi
		done
	fi
done
Thanks,
Ted
 
Old 08-24-2012, 11:15 PM   #2
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 431

Original Poster
Blog Entries: 32

Rep: Reputation: 3
Use 2>&1 /dev/null to save the output into a string and compare with if but if anyone has a better method plz let me know.
Thanks ted
 
  


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
Permission Denied Error? your_shadow03 Linux - Newbie 5 12-10-2009 01:38 PM
permission denied error aahiqmir Linux From Scratch 1 03-30-2009 01:51 AM
permission denied error mjalalynia Linux - Desktop 2 07-26-2008 01:28 AM
Permission Denied Error ckurowic Linux - Server 7 05-18-2007 03:33 AM
permission denied error endezeichen Linux - General 5 12-20-2003 06:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:49 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