Computing Tips and Tricks

Windows/Linux Integration Tips Windows Tips Linux Tips General Computing Tips

Fixing Windows 2000 Printing to a Red Hat 7.3 Samba Server

OK, if you use Windows 2000 and print to a Red Hat 7.3 Samba server, you've undoubtedly gotten that annoying "Access denied: Unable to connect" message. What's causing that is a missing parameter in the Samba configuration file, that tells Windows 2000 to properly treat the printer as a remote device and not locally attached. To fix this, change the [printers] section of /etc/samba/smb.conf to:

[printers]
   comment = All Printers
   path = /var/spool/samba
   browseable = no
# Set public = yes to allow user 'guest account' to print
   guest ok = yes
   writable = yes
   printable = yes
   use client driver = yes

The important parameter is the last one. The other changes from the default Red Hat configuration might be irrelevant, but I haven't tested them, and this just works :-)

But Wait, There's More!

So you can connect, but now your print jobs never finish because they're always paused, right? Wrong! The printing daemon is doing something stupid, not deleting finished print jobs from the queue. Why this is default is anybody's guess. To fix this, add these lines to /etc/lpd.conf:

stalled_time=300
done_jobs=0

The first parameter tells the printing daemon to wait for 5 minutes before designating a print job as frozen. The default is 2 minutes (grrr!). The second line is the important one, as it tells the daemon to not keep any finished jobs in the queue.

All Good

Now everything is happy. You can browse the Samba printer, and your jobs actually go away when they're done printing! Of course, this system will probably introduce other problems (re-queueing of jobs comes to mind), but it works here. If you're having issues, email me.

If It Ain't Broke Then Fix It

To move to Cups printing, you first have to set the printing system to use cups. You then have to make a few more edits for samba. First set cups as the default printing system:

# /usr/sbin/alternatives --config print
reading /var/lib/alternatives/print

There are 2 programs which provide 'print'.

  Selection    Command
-----------------------------------------------
   1           /usr/bin/lpr.cups
*+ 2           /usr/bin/lpr.LPRng

Enter to keep the default[*], or type selection number:

Type 1 and hit enter. Now would be a good time to stop the current LPRng pring server, and to start the new cups print server:

# service lpd stop
# service cups start

You have to now set up the printer. Point a web browser on the local machine to http://localhost:631. Log in as the root user.

Now to edit the samba config files to use cups printing. First, change line 38 in /etc/samba/smb.conf from:

printing = lprng

to

printing = cups

Then, uncomment line 83 in /etc/cups/mime.convs:

#application/octet-stream        application/vnd.cups-raw        0       -

and also uncomment line 152 in /etc/cups/mime.types:

#application/octet-stream

Restart the samba services from the shell:

# service smb restart

Update for PLC Printers

Dave Cinege wrote to give a tip for anyone with a Lexmark Optra R+, or any other printer that supports both PLC and PS inputs. Even after following the above the printer still refused to work. As Dave remarked:

Here's why: I was using a the native Postscript driver under Windows, and CUPS was filtering and (trying to) process this. Switch the w2k client to use the PLC, fixed all. I've not taking the time to figure out how to fix it right (IE PS from w2k doesn't make CUPS croak). I'll leaving that to someone with more time.


Turning off Webpopup Spam in Windows

If you've gotten any of those extremely annoying spams that advertize free university diplomas and such, here's how to get rid of them. Go into Administrative Tools->Services. Open up the Messenger service. Change the startup type to manual, and be sure to stop the service immediately.

Getting Tab Completion in a Windows Shell

File and directory name tab completion are available under the "Cmd" tab of the TweakUI control panel. This is not a standard part of windows, but an optional add-on available from Microsoft.

If you are running Windows NT, 2000:

http://www.microsoft.com/ntworkstation/downloads/PowerToys/Networking/NTTweakUI.asp

If you are running Windows XP:

http://www.microsoft.com/windowsxp/pro/downloads/powertoys.asp

Doing this without TweakUI:

  1. Open regedit
  2. Browse to this folder: HKEY_CURRENT_USER\Software\Microsoft\Command Processor
  3. Change the value of CompletionChar from 0 to 9

Reference: http://www.allthingsgeek.net/modules.php?op=modload&id=News&file=article&sid=54

Determining Uptime in Windows NT/2000/XP

So you know about "uptime" on Linux, to see how long the computer has been up. What's the equivalent on Windows, to see how long it's been since the last major security hole was patched? (5 days in my case) A simple way is to use the "net" command:

net statistics workstation

At the top of the output, which may scroll out of the immediate terminal view, you'll see the line:

Statistics since XX/XX/XXXX XX:XX XX

Now, this value is tied to networking, but who runs a machine without networking anymore?

Getting "Press any key to continue" in Windows

Found this great site today that shows how to keep your console programs from automatically terminating, in both Unix and Win32. The relevant code is:

#include <windows.h>
#include <iostream.h>

int main(int argc, char* argv[])
{
     HANDLE hStdIn;
     DWORD numIn;
     CHAR c;

     cout << "Press any key to continue" << endl;
     hStdIn = GetStdHandle(STD_INPUT_HANDLE);
     SetConsoleMode( hStdIn, ENABLE_PROCESSED_INPUT ); 
     FlushConsoleInputBuffer( hStdIn );
     ReadConsole(hStdIn, &c, 1, &numIn, NULL );

     return 0;
}

Broken mkfs.msdos (and mkfs.vfat) on RedHat 7.3?

If you've ever gotten the error message:

mkfs.msdos: unable to allocate space for FAT image in memory

try first overwriting the disk with all zeros:

$ dd if=/dev/zero of=/dev/fd0

Replace /dev/fd0 with the appropriate device node that you are trying to format.

Getting Letter Paper Size in PDFLatex

PDFLatex keeps giving you A4 sized documents? Running texconfig doing nothing to change that? Here's how to fix it. Open /usr/share/texmf/pdftex/config/pdftex.cfg in your text editor. Change the lines:

page_width 210truemm
page_height 297truemm

to

page_width 215.9truemm
page_height 279.4truemm

Viola! More information here.

Making XMan Work in Red Hat 7.3

If you're getting

Xman Error: No manual pages found.

Add the following lines to /etc/profile

MANPATH=/usr/share/man:/usr/man
export MANPATH

Log out and log back in.

Update! (26 October 2002) I'm happy to report that in my install of Red Hat 8.0, xman works just fine by default.

Fixing the Console Font in Red Hat 8.0

If you're seeing crazy characters in your Konsole when viewing man pages, yet plain old xterm works fine, here's what I found. The default language chosen by Red Hat in 8.0 is

en_US.UTF-8

not the usual

C

So, as root edit /etc/profile.d/lang.sh, and make the last two lines of the file:

LANG=C
export LANG

Log out, and log back in.

Dual Monitors using a GeForce 4 on Linux

So you've noticed that your brand spanking new GeForce 4 card has 2 monitor outputs. You have that ancient 17" in the closet... maybe you could use it for keeping some of those xterms always in view. That was my plan anyway. I bought a Gainward Ultra/650 TV card, so YMMV with other versions.

First off, you must be running the official NVidia drivers. If you have an NVidia card and you're running the standard XFree86 drivers, upgrade immediately, even if you're not doing OpenGL or 3D gaming, because this dual monitor stuff requires features that only the official drivers support.

Once you're running the official drivers, read the NVidia README to determine how you want your monitors configured. Here's how I did it:

Section "Device"
        Identifier  "Videocard0"
        Driver      "nvidia"
        VendorName  "Videocard vendor"
        BoardName   "NVIDIA GeForce 4 (generic)"
        BusID       "PCI:1:0:0"
        Screen      0
        Option      "NoLogo"
        Option      "CursorShadow" "on"
        Option      "CursorShadowXOffset" "2"
        Option      "CursorShadowYOffset" "2"
        Option      "TwinView"
        Option      "TwinViewOrientation" "RightOf"
        Option      "MetaModes" "1280x1024,1024x768; 1280x1024,NULL"
        Option      "ConnectedMonitor" "CRT, CRT"
        Option      "SecondMonitorHorizSync" "30.0 - 50.0"
        Option      "SecondMonitorVertRefresh"  "60.0 - 70.0"
        Option      "IgnoreEDID" "true"
EndSection

My setup consists of a beautiful Samsung 19", and a rather old Sony 17". I wanted the Sony to be the right screen, as the left screen by default becomes the home screen, with your panel and such. So, the above options turn on TwinView (that's how NVidia does the dual monitor with XFree86), sets the resolutions for the monitors, tells the card that both outputs go to CRT screens, sets the refresh rates, and finally tell the card to ignore what it auto-detects.

This was necessary for me as my older monitor is not plug and play, and the card could not detect its settings. On Windows this made the monitor unusable, but on Linux you can override the driver defaults (more proof that Windows sucks). In the "MetaModes" line, you'll see two listings. The first is the default resolutions. The second is automagically activated when running one of the many great games for Linux. Without this, the game will default to the center of the X display area, which unfortunately is half on the left monitor and half on the right :-(

Some other options of note include turning off that stupid NVidia advertisement when starting X (NoLogo) and turning on the mouse cursor shadow, like Windows 2000/XP have. This is perhaps unnecessary, but I think it looks much better, and since it's probably done wholly in hardware, it won't affect your system performance much at all.

Here is my entire XF86Config file. Most is autogenerated, so don't expect drastic insight. I'm told that the next version of XFree86 will (finally!) allow for realtime GUI control of X resolutions, so editing this file by hand will hopefully become a thing of the past.

2.5 Kernel on Red Hat 8.0

If you're trying out the newest Linux kernels (the 2.5 series) on Red Hat 8.0, here's a tip that nobody seems to make obvious. You need to upgrade your modutils package, otherwise you'll get this message whenever you try doing anything module-related:

QM_MODULES: Function not implemented

Install the appropriate modutils source code package:

rpm -Uvh http://www.kernel.org/pub/linux/kernel/people/rusty/modules/modutils-2.4.21-11.i386.rpm

Then, build the package:

rpmbuild -bb /usr/src/redhat/SPECS/modutils.spec

And finally, install the new package:

rpm -Uvh --force /usr/src/redhat/RPMS/i386/modutils-2.4.21-11.i386.rpm

Backing up Directories using SSH

To back up a directory from a remote machine to your local account, use the following command:

ssh otherhost.yourdomain.net "tar cvfz - /home/account" > backup.tar.gz

On slower machines, you may want to leave off the compression:

ssh otherhost.yourdomain.net "tar cvf - /home/account" > backup.tar

Note: I originally saw this somewhere else, but I found this great tip again here.

Fixing the weird PCI issue in Fedora Core 1

Having installed Fedora Core 1, my computer was having just the strangest issues with my standard 3Com ethernet card. I was getting bizarre messages like:

eth0: Transmit error, Tx status register d0.

Also, my event log was just filled with interesting 3c59x driver error messages.

I found the solution here. Add to your /etc/modules.conf file (as root):

alias eth1 3c59x debug=0 options=4 full_duplex=1

Using the NVidia drivers in Fedora Core 1

The Nvidia supplied Linux driver packages won't compile by default on Fedora Core 1. I found a solution here. First download the Nvidia Linux drivers (they were here the last I checked). Then, as root, run the following commands:

rpm -e --nodeps XFree86-Mesa-libGL
sh NVIDIA-Linux-x86-1.0-4496-pkg2.run --add-this-kernel
sh NVIDIA-Linux-x86-1.0-4496-pkg2-custom.run

The Nvidia installer program should be pretty self explanatory. Modify your /etc/X11/XF86Config file to look something like this:

Section "Module"
Load  "dbe"
Load  "extmod"
Load  "fbdevhw"
Load  "glx"
Load  "record"
Load  "freetype"
Load  "type1"
Load  "dri"
EndSection

The important modules are the glx and dri ones. I've had no problems so far by doing this.


Getting Letter Paper as Default in OpenOffice

Make a new text document. Set the margins and paper size. Save the file as an OpenOffice Template, in ~/.openoffice/user/templates/default . Open File->Templates->Organize. Double click on the default folder, right click on the filename that appears, and then select "Set as Default Template".

You may also want to set the default paper under Printer Administration, under the File menu.

Easily Restricting Access to Web Folders in Apache

If you are sharing a directory with Apache, yet don't want say the MPAA to be able to read it, you can limit access to that folder by domain name. Open httpd.conf and change the line:

AllowOverride None

To:

AllowOverride AuthConfig Limit

For me, with the standard Red Hat configurations, this is line 487 in Red Hat 7.3 and line 329 in Red Hat 8.0. Then, in your directory, create a text file named ".htaccess". Make the contents of that file like the following:

deny from all
allow from sis.pitt.edu
allow from cmu.edu

Change the domain names to what you want of course.

C, C++ Angle Computations

If you work frequently with angles and triangles like I do, you'll often come across the problem of computing the angle associated with two sides of a right triangle. Here's my code to get the angle:

// first get the angle from atan
rotation = atan(dy / dx) * 180.0 / 3.14159265;

// then convert into the conventional 0 - 360 degrees format
if(dy <= 0.0 && dx >= 0.0) {
     rotation += 180.0;
} else if(dy <= 0.0 && dx < 0.0) {
     // nothing to do here
} else if(dy > 0.0 && dx >= 0.0) {
     rotation += 180.0;
} else if(dy > 0.0 && dx < 0.0) {
     rotation += 360.0;
}

Entity State Orientation to Pitch, Roll, Yaw

I spent hours and hours trying to understand how to convert the Euler angles in DIS entity state PDUs into conventional pitch, roll, and yaw. I eventually found the answer buried in OTBSAF source code, which I've cleaned up and condensed. I've only tested heading, and even then the arguments were reversed in the original source, so you might have to experiment a bit to get it right. Please drop me a line if you try the code.

/* psi, theta, and phi from entity state PDU */
double cos_psi = cos(psi);
double sin_psi = sin(psi);
double cos_theta = cos(theta);
double sin_theta = sin(theta);
double cos_phi = cos(phi);
double sin_phi = sin(phi);

double rot[3][3]; /* Rotation matrix */
#define X 0
#define Y 1
#define Z 2

rot[X][X] = sin_psi * cos_theta;
rot[X][Y] = cos_psi * cos_phi + sin_psi * sin_theta * sin_phi;
rot[X][Z] = - cos_psi * sin_phi + sin_psi * sin_theta * cos_phi;
rot[Y][X] = cos_psi * cos_theta;
rot[Y][Y] = - sin_psi * cos_phi + cos_psi * sin_theta * sin_phi;
rot[Y][Z] = sin_psi * sin_phi + cos_psi * sin_theta * cos_phi;
rot[Z][X] = sin_theta;
rot[Z][Y] = - cos_theta * sin_phi;
rot[Z][Z] = - cos_theta * cos_phi;

double pitch = asin(rot[Y][Z]);
pitch *= 57.29577951308232087679; /* Convert to degrees */
if(pitch < 0.0) pitch += 360.0;
if(pitch > 360.0) pitch -= 360.0;

double roll = atan2(rot[Z][Z], -rot[X][Z]);
roll *= 57.29577951308232087679; /* Convert to degrees */
if(roll < 0.0) roll += 360.0;
if(roll > 360.0) roll -= 360.0;

double yaw = atan2(rot[Y][X], rot[Y][Y]);
yaw *= 57.29577951308232087679; /* Convert to degrees */
if(yaw < 0.0) yaw += 360.0;
if(yaw > 360.0) yaw -= 360.0;

Chicken Taco Rice

Ok, so this really isn't a computer tip, sue me. Wait, I'm not serious! Anyway, this is one of my favorite recipes from home. It's simple (always a plus) and quite tasty too. Enjoy. (Copyright whoever owns this recipe)

A very fast and easy dish that will please the whole family.

1 pound boneless skinless chicken breasts -- cut into strips
2 tablespoons oil
1 can chicken broth
8 oz tomato sauce
1 package taco seasoning mix (make your own)
1 1/2 cups instant rice -- uncooked
1/2 cup shredded cheddar cheese
tortilla chips

In a skillet with a cover, saute the chicken in the oil until
opaque. Drain. Add chicken broth, tomato sauce, and taco seasoning
mix. Bring to a boil and simmer, covered for about 5 minutes, stirring
occasionally. Stir in the instant rice, cover, remove from heat and let
stand 5 minutes, until rice is tender.

Fluff with a fork, sprinkle with cheese and serve immediately, with
tortilla chips.

Corn Flake Muffins

I've been searching for some time for a simple recipe like this, to make muffins out of normal cereal. I'm assuming that this works just as well with raisin bran, but I haven't tested it yet. I found this at http://www.mrbreakfast.com/superdisplay.asp?recipeid=1009.

Corn Flake Muffins

(12 servings)
 
1 and 1/4 cups all-purpose flour
1 Tablespoon baking powder
1/2 teaspoon salt
1/4 cup sugar
2 cups corn flakes
1 and 1/4 cup milk
1 egg
1/3 cup vegetable oil 

Sift together flour, baking powder, salt and sugar. Set aside. 
 
Stir corn flakes and milk together in a separate large mixing
bowl. Let stand about 2 minutes until cereal is softened. Add egg and
oil to this mixture. Beat well. Add flour mixture to wet mixture,
stirring only until combined. Portion butter evenly into 12 lightly
greased 2-1/2-inch muffin pan cups.
 
Bake at 400 degrees about 20 minutes or until lightly browned. Serve
warm.

Be aware of your oven. Mine runs hot and 30 minutes at 350 degrees
works better for me.  


Page written by Joe Manojlovich

[Home]

Valid XHTML 1.1! Valid CSS!