|
SCE |
Unix Lab FAQs
Directories:
Files:
The Unix Path: Floppy Disk Access:
The vi Editor:
Oracle and sqlplus:
C and C++ and Java Compilers: Web Applications:
Unix Shells and Scripts:
General
Questions
To find your username click on the following link and follow the directions on the website:
http://mypassportid.uhcl.edu Your username will be listed under the ROCKS system. Your password for your unix account is usually: s followed immediately by your social security number or s followed immediately by your seven digit student ID number If both of these do not work, email the System's Administrator for your password. No. Click on the following link and follow the directions on the website to find your ORACLE account name: http://oracle-p.uhcl.edu/pls/guest/pfs100$.Refresh_query Your username will be listed next to the ORA system. If the ORA listing is not available, look for your username next to the PC Lab listing. Passwords for the ORACLE accounts are s and your 7 digit student ID At the command prompt, enter: % passwd The system will prompt you for the old password and then for the new password. Printing to the line printer: lpr -Pasc name of your file to be printed with the extension Printing to the laser printer: lpr -Plaser name of your file to be printed with the extension There are many ways of doing this: a. If /usr/dt/bin is already added to your path, then at the command prompt enter: % netscape b. If /usr/dt/bin is not added to your path, then add it to your path and then at the command prompt enter: %netscape c. If /usr/dt/bin is not added to your path, then at the command prompt enter: %/usr/dt/bin/netscape At the command prompt, enter: % whatis name of the command The system will return a brief decription of the command. At the command prompt, enter: % man name of the command The system will return a detailed decription of the command. For example: % man man will give you the detailed description of the man command. To return to the prompt without reading the whole description, at the command prompt enter: % <cntrl>c Return
to Top
At the command prompt, enter: % uname The system will return the current operating system. To find the version of the operating system, at the coommand prompt enter: % uname -v Return
to Top
Directories
At the command prompt, enter: % pwd The system will return the path to you. Return
to Top
At the command prompt, enter: % mkdir directory-name Return
to Top
At the command prompt, enter: % cd path of the directory By path of the directory, we mean the location of the directory from the root. % cd d Return
to Top
At the command prompt, enter: % cd .. Return
to Top
At the command prompt, enter: % cd / Return
to Top
At the command prompt, enter: % cd Return
to Top
First go into the directory to be emptied. Then, at the command prompt, enter: % rm * The system will inform you if there is another directory
present in this directory. If so, at the command prompt enter:
% rmdir * Return
to Top
At the command prompt, enter: % rmdir name of the directory Return
to Top
At the command prompt, enter one of the following commands: % ls -R To read the output of the system one page at a time, pipe the command to more. That is, at the command prompt , enter: % name of the command | more Return
to Top
Files
At the command prompt, enter: % touch name of the file you would like to make Return
to Top
At the command prompt, enter: % mv [old file name] [new file name] Return
to Top
At the command prompt, enter: % cp [old file name] [new file name] Return
to Top
At the command prompt, enter: % rm file name Return
to Top
At the command prompt, enter: % ls Return
to Top
At the command prompt, enter: % ls -a This will list all files including the ones begining with a dot. or At the command prompt, enter: % ls .* This will list only the files begining with a dot. Return
to Top
At the command prompt, enter: % ls *_* Return
to Top
You can't - it isn't stored anywhere. Files have a last-modified time (shown by "ls -l"), a last-accessed time (shown by "ls -lu") and an inode change time (shown by "ls -lc"). The latter is often referred to as the "creation time" - even in some man pages - but that's wrong. Return
to Top
At the command prompt, enter: % rm ./-filename Return
to Top
The Unix Path
At the command prompt, enter: %echo $PATH Return
to Top
Open the file .login in your home directory (in the c shell).
Then add the following line to the file:
setenv PATH "$PATH" :the name of the path that you wish to add Save the .login file. Source the file by executing the following command at the prompt: % source .login Return
to Top
Floppy Disk Access
On many Sun hardware platforms, it is impossible to automatically
detect the presence of a floppy in the drive. Run the command
/bin/volcheck to ask volume management to check the floppy drive for media. After volume management detects the floppy, it will be automatically mounted in /floppy/<name_of_media> Return
to Top
The filemanager also has a menu item File> Check for Floppy which in effect, runs the volcheck command. Return to Top
When
formatting floppies, fdformat command will not put a file system
on the floppy, by default. Use the
fdformat -d flag to put a DOSfile system on it, or run the newfs command
newfs /vol/dev/rdiskette0/unnamed_floppy) to put a ufs file system on it.
Return
to Top
First check is to
see if volume management knows about it. The best way to check this is
to look in /vol/dev/rdiskette0 and see if there is something there. If
not, the volcheck command has not been run, or there is some hardware
problem.
Return
to Top
The vi Editor
To start using vi, at the command prompt enter : % vi filename The filename can be the name of an existing file or the name of the file that you want to create. Return to Top
For inserting press i and then start inserting. Return to Top
To save the file and quit vi editor, first check that you are in command mode by pressing ESC and then enter: :ZZ or :wq to both save and quit or :w to save file but not quit vi or :q! to quit Return to Top
To quit vi without saving the contents of the buffer to the file press the ESC key and then enter :q! . Return to Top
ESC, [n] operator [m] object Return to Top
:s/char to be searched/new char Return to Top
To move to: Next line down : j Start on next line down : + Previous line : k Start of previous line : - Left one character : h Right one character : l Go to first character of current line : ^ Go to last character of current line : $ To delete: Current word : dw Previous word : db Entire line : dd To end of line : d$ To insert: Insert text after the cursor : a Insert text before the cursor : i Append text at the end of the current line : A Insert text at the start of the current line : I Open a new line below the current line : o Open a new line above the current line : O Return to Top
Oracle and sqlplus
At the command prompt, enter: % sqlplus Return
to Top
When entering your password, oracle needs to know which database it should connect to. The database that you use is known as the nas database. At the password prompt, enter: % your-password@nas Return
to Top
Check the .login file in your c-shell. To do so, at the command prompt, enter: % more . login The ORACLE_BASE, ORACLE_HOME and the TWO_TASK environment variables need to be set to the following paths: setenv ORACLE_BASE "/orasw/oracle" setenv ORACLE_HOME "${ORACLE_BASE}/product/9.0.1/" setenv TWO_TASK "nas" setenv PATH "$PATH":${ORACLE_HOME}/bin If the variables are not set, please edit the .login file and include the above 4 lines.Now you need to make sure that the changes go into effect. This can be accomplished by executing the following command: % source .login Now run the command SQLplus, and this should take care of it. If you STILL have a problem, copy a new .login file into your directory from /compilers/usrlib by entering the following command at the prompt: % cp /compilers/usrlib/.login  . WARNING: You will lose all previous configurations made in the .login file. Now source the .login file and it should work. % source .login Return
to Top
C and C++ and Java Compilers:
If the source file is a C++ file, at the command prompt enter: % g++ filename.cc –o filename This will create the executable file named filename. If
the source file is a C file,at the command prompt enter:
% gcc filename.c –o filename Return
to Top
This means that your PATH does not contain the directory that has gcc or g++ in it. /usr/local/bin is where the executables for gcc and g++ reside. You can either give the full path to gcc in the following manner: % /usr/local/bin/gcc filename.cc –o filename or add /usr/local/bin to your PATH Return
to Top
% source .login Your account now points to the correct libraries that C and C++ requires. Return
to Top
The GNU Project Home page is located at: www.fsf.org/home.htm The GNU software documentation pages are located at: www.delorie.com/gnu/docs or cl.cam.ac.uk/textinfodoc/dir.html GNU links to Free Software Site Pages can be found at: www.fsf.org/links.html#FreeSoftwareDocumentation Return
to Top
At the command prompt enter: % javac filename.java -o filename This will create the object file filename. Now execute the command java -classpath .filename This will execute the file named filename Return
to Top
You need to have the following variables set in your environment. JAVA_HOME=/compilers/j2sdk1_3_1 J2EE_HOME=/usr/local/j2sdkee1.2.1 CLASSPATH=/faculty/abeyseke:/usr/local/j2sdkee1.2.1/lib/j2ee.jar:/compilers /j2sdk1_3_1/lib/emailmessages.jar:/compilers/j2sdk1_3_1/lib/mm.mysql-2.0.4-bin.jar Your also need to have the following included in your PATH variable: /compilers/j2sdk1_3_1/bin:/usr/local/j2sdkee1.2.1/bin Return
to Top
When compiling the program, make sure that the -lpthread option is added to the gcc or g++ command. If this is omitted, the program still compiles successfully, but you will not be able to actually execute the program. Return
to Top
Web Applications
A request has to be made, by the instructor to the systems adminstrator, on your behalf, in order for you to get web account. It should be required for a course that you are taking. If the request is approved, your instructor will be notified of your account information. Return
to Top
Your web page is created on diamond.rocks.uhcl.edu. Your URL will be http://diamond.rocks.uhcl.edu/username Return
to Top
Return
to Top
Return
to Top
The TOMCAT installation on the system can be viewed at http://diamond.rocks.uhcl.edu:8080 . Your TOMCAT files can be stored at /compilers/jakarta-tomcat-3.2.3/webapps/username and can be viewed at http://diamond.rocks.uhcl.edu:8080/username Return
to Top
A directory will be created for users at /compilers/jakarta-tomcat-3.2.3/classes/username to save their classes files. Return
to Top
Unix Shells and Scripts
At the command prompt, enter: % echo $shell Return
to Top
In general,
you can't, at least not without making special arrangements. When a child
process is created, it inherits a copy of its parent's variables (and current
directory). The child can change these values all it wants but the changes
won't affect the parent shell, since the child is changing a copy of the
original data.
Some special arrangements are possible. Your child process could write out the changed variables, if the parent was prepared to read the output and interpret it as commands to set its own variables. Also, shells can arrange to run other shell scripts in the context of the current shell, rather than in a child process, so that changes will affect the original shell. For instance, if you have a C shell script named "myscript": cd /very/long/path setenv PATH /something:/something-else or the equivalent Bourne or Korn shell script cd /very/long/path PATH=/something:/something-else export PATH and try
to run "myscript" from your shell, your shell will fork and run the shell
script in a subprocess. The subprocess is also running the shell; when it
sees the "cd" command it changes *its* current directory, and when it sees
the "setenv" command it changes *its* environment, but neither has any effect
on the current directory of the shell at which you're typing (your login
shell, let's say).
In order to get your login shell to execute the script (without forking) you have to use the "." command (for the Bourne or Korn shells) or the "source" command (for the C shell). I.e. you type . myscript to the Bourne or Korn shells, or source myscript to the C shell. If all you are trying to do is change directory or set an
environment variable, it will probably be simpler to use a C shell alias
or Bourne/Korn shell function. See the "how do I get the current directory
into my prompt" section of this article for some examples.
Return
to Top
The answer
depends on your Unix version (or rather on the kind of "echo" program that
is available on your machine). A BSD-like "echo" uses the "-n" option for
suppressing the final newline and does not understand the octal \nnn notation.
Thus the command is:
% echo -n '^G' where ^G means a _literal_ BEL-character (you can produce this in emacs using "Ctrl-Q Ctrl-G" and in vi using "Ctrl-V Ctrl-G"). A SysV-like "echo" understands the \nnn notation and uses \c to suppress the final newline, so the answer is: echo '\007\c' Return
to Top
In sh, use read. It is most common to use a loop like: while read line do ... done In csh, use $< like this: while ( 1 ) set line = "$<" if ( "$line" == "" ) break ... end Unfortunately csh has no way of distinguishing between a blank line and an end-of-file. If you're using sh and want to read a *single* character from the terminal, you can try something like: echo -n "Enter a character: " stty cbreak # or stty raw readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null` stty -cbreak echo " Return
to Top
Let us
first assume you are on a UNIX variant (e.g. 4.3BSD or SunOS) that knows
about so-called `executable shell scripts'. Such a script must start with
a line like:
#!/bin/sh The script is called `executable' because just like a real (binary) executable it starts with a so-called `magic number' indicating the type of the executable. In our case this number is `#!' and the OS takes the rest of the first line as the interpreter for the script, possibly followed by 1 initial option like: #!/bin/sed -f Suppose this script is called `foo' and is found in /bin, then if you type: foo arg1 arg2 arg3 the OS will rearrange things as though you had typed: /bin/sed -f /bin/foo arg1 arg2 arg3 There is one difference though: if the setuid permission bit for `foo' is set, it will be honored in the first form of the command; if you really type the second form, the OS will honor the permission bits of /bin/sed, which is not setuid, of course. Return
to Top
Add the script on this link to your perl scripts. It will convert the call from /local/bin/perl to /usr/local/bin/perl in your perl scripts. Return
to Top
If you
are sure the number of arguments is at most 9, you can use:
eval last=\${$#} In POSIX-compatible shells it works for ANY number of arguments. The following works always too: for last do : done This can be generalized as follows: for i do third_last=$second_last second_last=$last last=$i done Now suppose you want to REMOVE the last argument from the list, or REVERSE the argument list, or ACCESS the N-th argument directly, whatever N may be. Here is a basis of how to do it, using only built-in shell constructs, without creating subprocesses: t0= u0= rest='1 2 3 4 5 6 7 8 9' argv= for h in '' $rest do for t in "$t0" $rest do for u in $u0 $rest do case $# in 0) break 3 esac eval argv$h$t$u=\$1 argv="$argv \"\$argv$h$t$u\"" # (1) shift done u0=0 done t0=0 done # now restore the arguments eval set x "$argv" # (2) shift This example works for the first 999 arguments. Enough? Take a good look at the lines marked (1) and (2) and convince yourself that the original arguments are restored indeed, no matter what funny characters they contain! To find the N-th argument now you can use this: eval argN=\$argv$N To reverse the arguments the line marked (1) must be changed to: argv="\"\$argv$h$t$u\" $argv" If you allow subprocesses as well, possibly executing nonbuilt-in commands, the `argvN' variables can be set up more easily: N=1 for i do eval argv$N=\$i N=`expr $N + 1` done To reverse the arguments there is still a simpler method, that even does not create subprocesses. This approach can also be taken if you want to delete e.g. the last argument, but in that case you cannot refer directly to the N-th argument any more, because the `argvN' variables are set up in reverse order: argv= for i do eval argv$#=\$i argv="\"\$argv$#\" $argv" shift done eval set x "$argv" shift Return
to Top
|