LinuxQuestions.org
Visit Jeremy's Blog.
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 10-23-2008, 05:15 PM   #1
PerfectReign
Member
 
Registered: Apr 2005
Location: Los Angeles
Distribution: openSUSE / Ubuntu
Posts: 294

Rep: Reputation: 33
Set Default Printer on Network Login


I have googled this and found many answers for how to script this in Wintendo,
but not so much that's clear on how do do this in Linux (or openSUSE).

I am writing this on my laptop - openSUSE 10.3/32-bit KDE 3.5 - system. *I use
it for work both at work in my office and at my home office.

At work, I print usually to an HP LaserJet 1310 I have in my office. I also
occasionaly print to a workgroup printer such as one of our color laserjets
or a high speed b&w printer.

At home, I print to my wife's OfficeJet, connected via Samba to her Win2K
computer.

I want to have the system auto-switch my default printer in KDE/CUPS based on
teh IP Address of where the compuer is. Though I use DHCP at work, my first
two octets are always the same - 1.2.x.x - and I have a fixed IP at home -
192.168.0.102.

In googling, I see that there is a commandline to set the default printer -
lpadmin -d printername - which I suppose could be added to an initrc bash
file.
 
Old 10-25-2008, 04:32 PM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
I'll be blunt: You are lazy, and don't really deserve any help at all, but:

See man ifconfig
See man grep
See man bash for the if statement syntax
Then try these commands in a terminal:
Code:
foo=$(ifconfig | grep 192.168.0.102)
echo $foo
Try this both at work and at home. Notice the difference?
Now you can see how you might use if to execute different scripts to assign your default printer.

Eg
Code:
if [ "$foo" == "" ] then ...
Then write your script. If it doesn't work, post it here, and we'll (probably) help you.
 
Old 10-25-2008, 07:26 PM   #3
PerfectReign
Member
 
Registered: Apr 2005
Location: Los Angeles
Distribution: openSUSE / Ubuntu
Posts: 294

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by tredegar View Post
I'll be blunt: You are lazy, and don't really deserve any help at all, but:
Wow, SOMEBODY woke up on the wrong side of the bed today. To start off a post with an insult is not a very nice thing.

In any case, I don't do man pages. I gave up trying to read that gobblygook eons ago.

Still, I tried what you suggested:

Code:
kai@xwing:~> foo=$(ifconfig | grep 192.168.0.102)
bash: ifconfig: command not found
Not sure what the Foo command is. I did google it and came up with 37,700,000 responses. No time to look at it all.

Any other suggestions?

I'll google ifconfig, bash and grep. I assume you want me to write a bash script that somehow uses grep to find strings in the script and some output of the /sbin/ifconfig command.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Unable to autostart graphical login - default init set to 5 in /etc/inittab jrella SUSE / openSUSE 4 06-25-2008 07:27 AM
How do I set a default directory upon login with Samba? frentzel Linux - Networking 2 07-20-2006 06:42 AM
Can I set the default printer on a user level? robinBones Linux - Software 3 12-02-2004 07:40 PM
I want to set KDM for my default login manager njbrain Red Hat 1 02-26-2004 08:18 AM

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

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