This is a fairly common problem: you have a PC at home and you make some sort of connection over the internet to your server, but your application needs to print to your PC. That would be easier if your PC had a fixed, constant IP address, but your connection is dynamic so it changes.
There are many, many ways to solve this problem. So many, in fact. that I'll probably miss one or two in this write up. If I do miss something, do let me know: it may help someone else down the line.
Some of these methods involve configuring an LPD printer on your remote Windows machine. That's easy to do With Windows 2000 or XP and Windows LPD clients are easily found for other versions. A Google search for "Windows LPD Server" will turn up hundreds of options, free and low cost. The concept here is that you define an lpd printer on the server, and that its address will be looked up by name.. somewhere. Some of these even help you do that automatically, usually by way of something running on the server that their software can contact. Some things you might want to look at in this area include:
Other ways to do this are to use Windows SMB style printing. That will require Visionfs, Samba or FacetWin on the server and some help for those to "find" the connecting PC. Personally, I like the LPD solutions better, but in some situations the SMB way can be easy enough.
Some sample scripts for that are shown below.
# remotelpsetup, run at boot (run in background!)
/etc/fuser -k /dev/remoteprinters
/bin/rm -f /dev/remoteprinters
/etc/mknod /dev/remoteprinters p
while true
do
exec < /dev/remoteprinters
/usr/local/bin/updateremotelp
done
# pickprinter, called from user's .profile
set `/bin/who -mxu`
MYTTY=$2
MYADD=$6
MYALREADY=`grep $MYADD /etc/hosts| sed 's/ .*//'`
if [ "$MYALREADY" ]
then
MYADD=$MYALREADY
fi
test -z "$MYADD" && exit 0
case $MYTTY in
ttyp[0-9]*) :;;
*) exit 0;
esac
case $MYADD in
-) exit 0;;
192.168.*) exit 0;;
localhost) exit 0;;
*) : ;;
esac
while true
do
echo "Please select the printer you wish to use
1. Tiffany
2. Marilyn
3. Amelia
4. Susan
Q. Quit
"
PRINTER=""
read choice
case $choice in
1) PRINTER=TIFFANY;;
2) PRINTER=MARILYN;;
3) PRINTER=AMELIA;;
4) PRINTER=SUSAN;;
[qQ]) exit 0;;
esac
if test -z "$PRINTER"
then
:
else
echo "CookieM $PRINTER $MYADD" > /dev/remoteprinters
echo "Printer $PRINTER set for $MYADD"
exit 0;
fi
done
# updateremote
read key printer address
case $key in
CookieM) : ;;
*) exit 0;;
esac
/bin/grep -v $address /etc/hosts > /tmp/hosts.$$
/bin/grep -v $printer //tmp/hosts.$$ > /tmp/hosts2.$$
echo "$address\t$printer" >> /tmp/hosts2.$$
cp /tmp/hosts2.$$ /etc/hosts
/bin/rm /tmp/hosts.$$
Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)
| Views for this page | ||||
|---|---|---|---|---|
| Today | This Week | This Month | This Year | Overall |
| 16 | 16 | 296 | 7,159 | 32,067 |
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Sun Mar 18 16:34:16 2007: Subject: Thank you anonymous
Thank you. Very useful.
Tue Jul 15 05:29:47 2008: Subject: Thank you A. P. Lawrence AnupKatariya
Thank you for the knowledge you shared with All of us.
Add your comments
Lone-Tar Backup and Disaster Recovery
for Linux and Unix