My wife and I recently purchased a new Windows machine running Vista Home Premium. Our goal was to buy a machine to act as a backup location for the contents of our laptops as well as backup and storage for our digital photos and home movies. We also wanted a machine that could record TV programs for us. In short, we wanted a workhorse that would quietly sit in the background and ensure that we never lose anything. I struggled over the purchase because I would rather have a linux box, but given all the variables we were considering we decided Windows was best.
Overall we are happy with the new machine and getting it to work with my wife's laptop running Windows XP has been a breeze. As a few posts to come will show, it was a bit trickier getting files copied over from our old linux desktop and getting my linux laptop able to share with it.
Wednesday, September 19, 2007
Tuesday, September 18, 2007
Text to Postscript: a2ps
Sometimes I need to convert a text file to a postscript file either to print it or to include it in a paper as an eps file. To do this, I use the
If I just want to print a text file for my own viewing, I do the most basic:
This tells
In this next example, I wanted to create an eps file out of some code. I wanted line numbers, no headers, and no borders. I did it using the following:
Not surprisingly,
a2ps command, but as with symlinks, I tend to forget the options. The man page for a2ps is quite useful. Just for fun, I give some examples of how I use a2ps below.If I just want to print a text file for my own viewing, I do the most basic:
a2ps my-file.txt -o my-file.psThis tells
a2ps to take the input file my-file.txt and print it to the ps file my-file.ps. By default, this puts two virtual pages per sheet of paper as well as borders around columns. It also adds header and footer information about the file. If you want to print more virtual pages per sheet, you can add a flag with the number of pages per sheet up to nine. So if you want four per sheet, change the above to:a2ps -4 my-file.txt -o my-file.psIn this next example, I wanted to create an eps file out of some code. I wanted line numbers, no headers, and no borders. I did it using the following:
a2ps code-file --borders=no -B --line-numbers=1 -1 -o output-file.epsNot surprisingly,
--borders=no turns off borders. -B turns off headers. --line-numbers=1 tells a2ps to print every line number. -1 prints a single page per sheet of paper and -o output-file.eps tells a2ps the name of the output file. Obviously, replace code-file and out-put-file.eps with the file names you want. Again, the man pages include useful information about these and other options.
Making Windows a Bit More Linux-like: PuTTY and PSCP
When I'm using a Windows machine, I often need to ssh into a linux box or copy files from a linux box to the Windows machine. Two utilities make this very easy. PuTTY provides a terminal window for ssh'ing into linux machines and PSCP is a Windows version of scp for secure copying. Both can be found here.
When you download them, each comes as a small executable. I tend to leave the PuTTY executable in the directory I downloaded it to and create a shortcut to it on the desktop. Whenever I want to use it, I just double-click the shortcut. I like to put the PSCP executable someplace in the computer's path. Then to use it, I just open an MS-DOS terminal, change to the directory I want to copy to and copy files over with the command:
There's documentation on how to use PuTTY and PSCP here. For PSCP you can also look at the man pages for scp since the usage is the same.
When you download them, each comes as a small executable. I tend to leave the PuTTY executable in the directory I downloaded it to and create a shortcut to it on the desktop. Whenever I want to use it, I just double-click the shortcut. I like to put the PSCP executable someplace in the computer's path. Then to use it, I just open an MS-DOS terminal, change to the directory I want to copy to and copy files over with the command:
pscp remote-linux-box-address:path-to-files .There's documentation on how to use PuTTY and PSCP here. For PSCP you can also look at the man pages for scp since the usage is the same.
Monday, September 17, 2007
LaTeX, BibTeX, and Symbolic Links
The bane of my existence: multiple copies of the same file in different locations on my computer or computers. The copies may be identical or they may be of slightly different versions. I'm notorius for this and it confuses me to no end.
Here's an example: When I write papers, I use a bib file to store the BibTeX entries of my citations. With each new paper, I move the latest version of the bib file to the directory that contains the tex files of the paper and update the bib file with more entries as necessary. The result is that I have multiple versions of the same bib file strewn throughout my home directory.
Until now! In a move that did not take a lot of brain power, I created a directory
Why don't I just put the path to the original bib file into the \bibliography line of my tex file and dispense with the symlink? That would be the most convenient, but it could potentially cause some problems with uploading papers to submission sites. With the symlink, all references in the tex file will be to files in the same directory as the tex file. Therefore, I won't have to change any paths before uploading. The proof of course will be in the pudding. We'll see if this actually works.
Here's an example: When I write papers, I use a bib file to store the BibTeX entries of my citations. With each new paper, I move the latest version of the bib file to the directory that contains the tex files of the paper and update the bib file with more entries as necessary. The result is that I have multiple versions of the same bib file strewn throughout my home directory.
Until now! In a move that did not take a lot of brain power, I created a directory
~/latex/common-files and put my bib file in there. Now each time I create a directory for a new paper, I'll create a symbolic link in that directory to the bib file in my common-files directory. Hence, my last post about symlinks.Why don't I just put the path to the original bib file into the \bibliography line of my tex file and dispense with the symlink? That would be the most convenient, but it could potentially cause some problems with uploading papers to submission sites. With the symlink, all references in the tex file will be to files in the same directory as the tex file. Therefore, I won't have to change any paths before uploading. The proof of course will be in the pudding. We'll see if this actually works.
Symbolic Links
For some reason I have a mental block on how symbolic links work and have to do a Google search every time I want to create one. Maybe if I write a post about it, I'll break the block or at least have a handy reference for when I forget again.
According to Wikipedia, a symbolic link is a special type of file that points to another file. The difference between a symbolic (or soft link) and a hard link, is that if the user removes a symbolic link, the file it points to is unaffected, whereas if the user deletes a hard link, the original is deleted as well. The flip side according to these folks is that with a symbolic link if the original file is deleted, the link file is unusable. With a hard link, if the original is deleted, the link file preserves the data.
So here's how to create a symbolic link:
Replace original_file with the name of the existing file you want to make a link to and replace link_file with the name of the file you want to point to the original file.
According to Wikipedia, a symbolic link is a special type of file that points to another file. The difference between a symbolic (or soft link) and a hard link, is that if the user removes a symbolic link, the file it points to is unaffected, whereas if the user deletes a hard link, the original is deleted as well. The flip side according to these folks is that with a symbolic link if the original file is deleted, the link file is unusable. With a hard link, if the original is deleted, the link file preserves the data.
So here's how to create a symbolic link:
ln -s original_file link_fileReplace original_file with the name of the existing file you want to make a link to and replace link_file with the name of the file you want to point to the original file.
Subscribe to:
Posts (Atom)