Skip to content

Category: Unix Hint

printing postscript images to printer with gv (ghostview) as backup to evince

Bruce installed the gv package for viewing and printing postscript.  It works great for viewing.  For printing, it has problems.  Bruce developed this workaround (with a few mods by Joel):

‘gv’ uses the ‘lpr’ command, and if a printer as set as the default in CUPS it will use that printer automatically.  You can hear the printer warm up, but nothing comes out of the printer.

Fortunately ‘gv’ is packaged with a set of file conversion utilities,
including ‘ps2pdf’.  On the command line you can issue this command:

# ps2pdf xxx.ps – | lpr

and that will convert the ps file to pdf (version 1.4) before sending it to lpr.  (You can also convert in place – ie turn your postscript file into a pdf on disk with ps2pdf, and then send the pdf to the printer whenever you want.)

To print a ps on the fly, though:
gv’s print command dialog window has a typein labeled ‘print command’
and it’s automagically populated with the string ‘lpr’.  However you
can change that string to ‘ps2pdf %s – | lpr’.  You can also change
the default print string from ‘lpr’ to whatever you want in
GhostScript options, but that would break printing of non .ps Here’s.

To change the default print string in ‘gv’, select:

State->Setup Options

… Look for the Print Command field, and change the value from
‘lpr’ to ‘ps2pdf %s – | lpr’ (w/o the single quotes).

The change is saved to ~/.gv as the line:

GV.printCommand:        ps2pdf %s – | lpr

 

–bruce via joel

To access weekly online backup on canopus last updated 2024 August

Newest update 2024 Aug to reflect that backups are have been stored on canopus: for several years:

Go to canopus:/thuban2-backups

Bruce has an automatic (cron) job do a weekly backup of thuban onto canopus.

On canopus,

df -h gives the various mount points, incl
“Filesustem” /dev/mapper/centos_canopis-thuban2–backups”\
” Mounted on”  /thuban2/backups

Navigate down to whatever file you’re looknig for, and copy over to a safe place (Careful: do not overwrite newer file of same name on thuban!)

See also post on root superuser privileges on thuban2  (although current post you are reading deals with canopus, which is where weekly backups are stored).

–joel

adding titles to postsript file displays on screen

The following was significantly updated on 30 May 2012 and again on Aug 2014:

idl and pgplot and many other postscript plotting routines have this annoying “feature” wherein, the output postscript file, when displayed with evince (“evince <filename> &”), goes into a window whose banner does NOT give its filename.  This is confusing if one is looking at multiple files.  We would prefer that the banner gives the name of the displayed file.

E.g., if the postscript file was produced with pgplot,  the window banner says “PGPLOT postscript plot”, rather than giving the file name.

E.g., if the postscript file was produced with IDL,  the window banner says “Graphics produced by IDL”, rather than giving the file name. (NOTE ADDED AUG 2014: YUPING HAS CREATED A SCRIPT INSIDE IDL TO GENERATE A FILENAME TAG ON PS FILES. SEE HIS POST!)

The reason is, that it writes into the file itself that the title is “PGPLOT postscript plot”; i.e., it literally writes “%%Title: PGPLOT postscript plot”
(or something similar for the IDL) into the postscript file.

After much effort, I have realized that evince will automatically display the desired filename rather than the above useless info, if only
one eliminates the whole “”%%Title” line.  (My first solutions, rather than eliminating that line, wrote the filename in the “%%Title” line.)

Inside IDL itself, I  think it is not possible either to alter or to eliminate the %%Title line as the postscript file is written because the drivers are proprietary.  Therefore one must fix the postscript file afterwards.  (The web shows how to run a unix script inside IDL that does so.)

Inside pgplot itself, one CAN fix the drivers so as to eliminate the offending %%Title line: Go to  drivers/psdriv.f

———–

To fix up a postscript file after the fact:

Joel has written a script (whose original was made and embellished by Joe Swiggum), joelpslabel, which

1. writes a new file whose name is the same as the original postscript file except
–Its name has an added “label” before the dot in the original file name
–Its modification date is listed as being identical (at least to the minute) with the original file name  (as in “ls -al”) so that you know when the original was created. (This was hard!!!!!!!!!!!!)

2. The script then runs evince on the new file, thereby putting on the screen something identical to the old file but with a banner that gives the old file name

———————

The new file with the new name having “label” in it stays on disk, and the original file is untouched, and they both have the same (claimed) date on them.  I do this because an older version of this script, which actually overwrote the original, sometimes got confused and the original was destroyed, requiring an archival search of old backups.  The downside is of course twice as much disk space but hey disk space is cheap and easy these days.

One can run joelpslabel on the original file as many times as one likes – each time overwriting the “new” file but assigning it the date of the orig file.

One can also run evince on the new file infinite times. The only downside there is that the banner will give the newfilename the 2nd-infinite time, rather than the old file name.  (The newfilename = oldfilename + “label”)

Known problem: The script searches for the first “.” in the filename and places “label” before it, so if your filename has more than one dot before “ps”, the name will be very screwy.  joel.weisberg.ps -> joellabel.weisberg.ps

Printer diagnostics – cups and printer API

To go to the CUPS printer GUI, in firefox go to http://localhost:631

To go to the printer API itself, go to http://137.22.12.71 for olin 304 6350 printer.  The startup page for each printer will give its IP address.

 

Thanks Bruce!

Handy Keyboard Chords

Due to the current instability with the GNOME environment, here are a few handy key chords to help reset the X windows server.

Press: 
Control-Alt-Backspace To: Kill all running processes attached to the X-Server on the computer and restart the X-Server, Note: As this ends all tasks associated with the X-Server, only use this one if you just turned the computer on or know nobody is using it, though it is the fastest way to restart X and is the only key chord that has any chance of returning GNOME to a functioning state.
                                      
Control-Alt-F1 To: Take you to init-1 (command line), pausing the X server, but not disrupting any open processes. From this command line many smaller tasks can be accomplished, provided that they do not need a separate window to operate.

Control-Alt-F7 To: Bring you back to init-7, (resuming X), use after Control-Alt-F1 to resume the windowing server. You should wait roughly 10 seconds in between using the two commands or the X server will get a little confused. Note: This pair of commands will never bring GNOME back to life, but if you want to work on the computer you can use the init-1 environment to do many simpler tasks.

For more information, as well as a whole host more key combinations please see this website.

Additionally, if one of the computers refuses to cooperate, it is possible to ssh in to any of Linux computers from any *nix system on campus (either a lab Mac, another Linux box, or your own laptop for that matter). To do so type:

ssh -Y username@hostname.physics.carleton.edu

And then enter your password when prompted.

So, for example,

ssh -Y cerjanb@deneb.physics.carleton.edu

Would log me in (provided I entered the correct password) as cerjanb on Deneb.

nautilus file manager startup in chosen directory from command line

To start up nautilus in a given directory from command line, simply type

nautilus <dirname> &

remember that . is a name for the current directory.  So nautilus . & will open a nautilus file manager in whatever directory the terminal is in.  This is the inverse of hitting the f4 key in nautilus which opens an xterm in the same directory that konqueror is in.

–Joel

How fix “Firefox already in use” problem

Our shared home directories sometimes confuse Firefox, causing it to fail to launch while posting a dialog window saying that “Firefox is already in use”.

The only solution I’ve found that really works is somewhat drastic. It requires you to delete your ~/.mozilla/firefox directory, which has the effect of deleting your bookmarks.

To preserve your bookmarks, we must first export them to a temporary location, exit Firefox, delete your ~/.mozilla/firefox directory, relaunch Firefox, and then import your bookmarks from the temporary location.

Here’s the step by step solution:

1. To get Firefox to launch (in a somewhat hosed state) so that you can save your bookmarks, open a terminal window and issue these commands:

rm -f ~/.mozilla/firefox/*.default/lock
rm -f ~/.mozilla/firefox/*.default/.parentlock

2. Launch Firefox. It will be somewhat hosed, but you should be able to export your bookmarks by opening the Bookmarks window by selecting “Bookmarks->Organize Bookmarks” from the Browsers menu. Once the Bookmarks window appears, click on the “Import and Backup” menu and select “Backup”. A “Bookmarks backup” window will pop up prompting you for a location to save your bookmarks to. Just go with the default values, which should save a “Bookmarks <date>.json” file to your Desktop.

3. Exit Firefox

4. From a terminal window, issue this command:

rm -f ~/.mozilla/firefox/

5. Launch Firefox. At this point Firefox should behave normally and you can restore your bookmarks by opening the Bookmarks window and selecting “Bookmarks->Organize Bookmarks” from the Browsers menu. Once the Bookmarks window appears launched, click on the “Import and Backup” menu and select “Restore”. A dropdown list of of bookmark backup files should pop up, and you can select the most recent one to restore your bookmarks.