LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-23-2008, 03:46 PM   #1
lefty.crupps
Member
 
Registered: Apr 2005
Location: Minneap USA
Distribution: Debian, Mepis, Sidux
Posts: 470

Rep: Reputation: 32
Angry Bash script for adding SMB/Windows printer to CUPS failing, why??


I am trying to create a simple command-line script for a RHEL5.1_64 system to add shared Windows printers to their Linux server. When I run this command alone at a bash prompt, it works:

Code:
lpadmin -p michele1320pcl6 -v smb://Administrator:PASS@michele/michele1320pcl6 -E
But when I put that into a script, I get no successes and a lot of errors in the cups/error_log. Here is my script:

Code:
#!/bin/bash
echo -e "\n"
echo -e "Please enter the Windows computer name, which must not have spaces:"
read COMP
echo -e "Please enter the printer's Share Name, also without spaces:"
read PRINTER
echo -e "Please enter the desktop Administrator's password:"
read PASSWD
clear
echo -e "\n\nDoes this look correct? \n\t Computer: $COMP \n\t Printer:  $PRINTER \n\t Password: $PASSWD \n If this is wrong, press [Ctrl][C] to stop this program; otherwise press [Enter] to add your printer. \n\n"
read PAUSE
/usr/sbin/lpadmin \-p $PRINTER \-v smb://Administrator:${PASSWD}@${COMP}/${PRINTER} \-E
echo -e "\n"
echo -e "Printing test page now to $PRINTER"
/usr/bin/lpr -P "$PRINTER" /root/printtest.txt
echo -e "\n"
The errors are generally "Tree connect failed (NT_STATUS_BAD_NETWORK_NAME)" but I get others also, depending on if I try to \@ escape the @ symbol in the "-v URI" string; I've tried with and without quotes, with and without \-v \-E, but no matter what I cannot get it.

Any ideas out there for me?
 
Old 04-23-2008, 08:50 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by lefty.crupps View Post
I am trying to create a simple command-line script for a RHEL5.1_64 system to add shared Windows printers to their Linux server. When I run this command alone at a bash prompt, it works:

Code:
lpadmin -p michele1320pcl6 -v smb://Administrator:PASS@michele/michele1320pcl6 -E
But when I put that into a script, I get no successes and a lot of errors in the cups/error_log. Here is my script:

Code:
#!/bin/bash
echo -e "\n"
echo -e "Please enter the Windows computer name, which must not have spaces:"
read COMP
echo -e "Please enter the printer's Share Name, also without spaces:"
read PRINTER
echo -e "Please enter the desktop Administrator's password:"
read PASSWD
clear
echo -e "\n\nDoes this look correct? \n\t Computer: $COMP \n\t Printer:  $PRINTER \n\t Password: $PASSWD \n If this is wrong, press [Ctrl][C] to stop this program; otherwise press [Enter] to add your printer. \n\n"
read PAUSE
/usr/sbin/lpadmin \-p $PRINTER \-v smb://Administrator:${PASSWD}@${COMP}/${PRINTER} \-E
echo -e "\n"
echo -e "Printing test page now to $PRINTER"
/usr/bin/lpr -P "$PRINTER" /root/printtest.txt
echo -e "\n"
The errors are generally "Tree connect failed (NT_STATUS_BAD_NETWORK_NAME)" but I get others also, depending on if I try to \@ escape the @ symbol in the "-v URI" string; I've tried with and without quotes, with and without \-v \-E, but no matter what I cannot get it.

Any ideas out there for me?
Why are you escaping the dashes?

/usr/sbin/lpadmin -p $PRINTER -v smb://Administrator:${PASSWD}@${COMP}/${PRINTER} -E

... a bash shell script should be the same as typing in a bash shell, so unless you're trying to echo something out, there's no reason to escape anything (unless you would escape it when you type it on the command line).
 
Old 04-24-2008, 10:10 AM   #3
lefty.crupps
Member
 
Registered: Apr 2005
Location: Minneap USA
Distribution: Debian, Mepis, Sidux
Posts: 470

Original Poster
Rep: Reputation: 32
I should have been more clear; when I wrote "I've tried with and without quotes, with and without \-v \-E" I meant, with the escape in \-v and \-E, and without the escape (just -p and -v and -E, not escaped).

So, I've tried both:

/usr/sbin/lpadmin \-p $PRINTER \-v smb://Administrator:${PASSWD}@${COMP}/${PRINTER} \-E
/usr/sbin/lpadmin -p $PRINTER -v smb://Administrator:${PASSWD}@${COMP}/${PRINTER} -E

I have bigger issues, I think. I can connect to another samba share when I mount it but I have browsing issues (like I can cd /mnt/winshare/fakedir/thisisreallyfake/ and run an ls -a there, and it shows me the same as /mnt/winshare/ ...)

Last edited by lefty.crupps; 04-24-2008 at 11:42 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
Print directly to Windows network printer within a bash shell script jwillyuaz Linux - Newbie 1 02-12-2008 02:15 AM
Quick question for adding smb support to Cups tgo Linux - Software 6 01-31-2007 05:17 AM
adding smb printer under cups glock19 Linux - General 1 01-31-2007 05:14 AM
Linux-to-Windows printer via CUPS/SMB, job aborts haertig Linux - Networking 1 02-18-2006 07:16 PM
Adding SMB printer in OpenOffice thordog Linux - Networking 0 10-09-2002 10:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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