Some general questions that students frequently ask are posted below, along with answers. I have also answered questions specific to lecture topics and course organization via email. A selection of those questions (and complaints), and my responses, are viewable here.
Where can I learn about Unix, HPs, etc?
The CS department has its own FAQ answering many such questions.
How can I read and write on an MSDOS-format floppy disk using Unix?
On an HP workstation that has a floppy disk drive, use various dos commands. Another FAQ lists some of the commands. You can also use the command man -k dos to list the commands, and then use man to get specific information for each command.
Under Linux, it is best to use the mtools that provide a look-alike substitute for DOS file commands tailored to the floppy drive (even using a: to designate the floppy drive!). A copy of the Linux man pages for mtools is located here. Usually, we use the mcopy command under linux to work with DOS floppies, and it has a syntax quite similar to the DOS copy command. Here are some examples.
Copies project.c from the floppy to the current working directory.
mcopy segpr.c a:
Copies segpr.c to the floppy.
mdir a:Lists (just like the DOS dir command) the floppy's directory.
What can I do about the funny ^M characters?
You see the ^M character when using a Unix editor such as vi when you edit a file produced by MS/DOS or other similar system. The problem is that lines in files created by Unix end with one special character (0x0A in hex, commonly known as \n by C programmers), but in the MS/DOS world, lines end with two special characters --- and one of these characters shows up as ^M when you edit the file under Unix.
So to fix the problem, just delete all the ^M characters from the file. Easier said than done. Here is what I usually do. Suppose we want to fix the file dosfile.c by removing the extra characters. Then use the Unix command:
tr < dosfile.c > hold -d "\015"Of course this creates a copy of the dosfile.c called hold, which you can look at and verify that it's what you want; if it is OK, rename it to dosfile.c, with the command mv hold dosfile.c.
How can I print or save the output from a man command ?
First, you need to find out where the text of the page you want to display is kept. Suppose you want to get, for example, the output from man gettimeofday. The first step is the hardest part --- you'll need to find the source file for the gettimeofday page. When you do a man gettimeofday command, you'll see, at the top of the man page, the character string
gettimeofday(2)This indicates that the page for gettimeofday is in section 2 of the man pages. The next step is to list out the sections of the man pages, which you do with the command ls /usr/man (for locally installed software, you may have to also do ls /usr/local/man or ls /usr/apps/man or ls /usr/pgk/man etc, depending on the whims of how the system administrator set up your system). You'll likely see a directory man2 listed, or perhaps a man2.Z directory, or something similar that implies section 2 of the pages. Now try a command such as
ls /usr/man/man2.Z/gettim*(or a similar variation in other directories; there are faster ways of tracking down the file using find as well on some systems). On the computer science HP systems, you'll see the response
/usr/man/man2.Z/gettimeofda.2Notice how the final y of the name was truncated (frustrating, but that's just the way it is). I recommend here that you copy this file to your own directory, so you can easily manipulate it.
cp /usr/man/man2.Z/gettimeofda.2 tempfile.ZThe letter Z above is an indication that the file copied was previously compressed (we suspect this because the directory name is man2.Z; when you see a file or directory name that has a suffix of .Z or .gz then it is very likely in compressed format). Now you'll need to uncompress the file with the command
gunzip tempfile.ZThis removes the file tempfile.Z and creates the file tempfile (see man uncompress or man gunzip if you want to know the details). Finally, we have something to work with. You may now edit the file tempfile, but you'll notice it is not exactly the man gettimeofday result you want! But we are almost done. All it takes now is the command
groff -man tempfile > output.psto format the page and store it in a file called output.ps, which will be a postscript file ready to print or display with the ghostview utility. On the other hand, if you want just an ascii-like output, the command
nroff -man tempfile | lp -dpXXXcould be used to print the pages directly to printer XXX. There a section on printing man pages in the departmental FAQ also, but with considerably less explanation.
How can I see the routing table?
On the Linux systems, this is easy: just use the route command with no operands or options, and it will display the current routing table. Unfortunately, this doesn't work on the HP systems, where the syntax for route is different. On the HP systems use the command netstat -rnv and you will get a representation of the routing table; the routing address and netmask are displayed together, as follows:
Routing tables Dest/Netmask Gateway Flags Refs Use Interface Pmtu PmtuTime 127.0.0.1/255.255.255.255 127.0.0.1 UH 0 47339 lo0 4608 188.8.131.52/255.255.255.255 127.0.0.1 UH 0 745489 lo0 4608 default/0.0.0.0 184.108.40.206 UG 24 786654 lan0 1500 220.127.116.11/255.255.255.0 18.104.22.168 U 29 3638857 lan0 1500In this somewhat cryptic output, we see that the netmask for 127.0.0.1 is 255.255.255.255, and that any destination address of the form 128.255.28.x will match the table's last entry, and be sent on the lan0 interface. Since the flag on the last line is U and not UG, the last line is not a gateway, so the "Gateway" column in the last line (showing 22.214.171.124) is not really meaningful --- the actual hardware address will be filled in from the ARP table using the 128.255.28.x destination address in the datagram.
How can I save to a file what I see on the terminal?
Sometimes it is useful to save a copy of command input and output at the terminal. The script command does this (you can read about script using man script). Simply type script to start recording all terminal output to a file; to stop recording, type exit.
% script myfile % ls /tmp % exit % more myfile Script started on Tue Jan 13 10:04:16 1998 touring:~$ ls / bin dev home usr boot etc lost.f touring:~$ exit exit Script done on Tue Jan 13 10:04:25 1998
Note: the output from script contains the annoying ^M characters, that you may want to remove.
This mystery was solved by the TA. It seems that some students earlier typed in the command copy myfile a: (or similar), which created a file called a: on the local directory! This confuses the mcopy command. The solution is to erase the a: file, with the command rm a: and then try your mcopy command again.