Wednesday, March 30, 2011

Permissions

add write access to current permissions for a filechmod g+w filename
remove all access for this directory and subdirectorieschmod -r go-rwx *
remove write access from everyone but youchmod go-w filename
replace current permissions for a file with those specifiedu=user, g=group, o=othersr=read, w=write, x=executechmod u=rwx,g=rwx,o=rwx filename
change group associated with fileschgrp newgroup filename
add all permissions for everyonechmod 777 filename
change ownership of fileschown newowner filename

Just Some Miscellaneous Notes

Man / More / Less

[Spacebar]  view next screen
[Enter]      view a line at a time
b            view previous screen
q                    quit viewing

Naming Files


  • The system will allow a file to be created with the same name as a directory.




  • The system will allow a space in a name, but some programs have trouble with it.




  • Use periods or underscores to separate characters.
  • Tuesday, March 22, 2011

    Documenting a Unix Script

    #! /usr/bin/ksh
    echo "# +-----------------------------------------------------------------------"
    echo "# | Program ID:    scriptname.sh"
    echo "# |"
    echo "# | Purpose:       description"
    echo "# |"
    echo "# | Developer:     Lynn Tobias"
    echo "# | Program Date:  mm/dd/yyyy"
    echo "# |"
    echo "# | Input File(s): /ux123/scripts/YES              -- 'Y' for prompts"
    echo "# |                /ux123/scripts/ods_uat.password -- sql+ password"
    echo "# |"
    echo "# | Table(s) Used: EXT_BLDLIST"
    echo "# |"
    echo "# | Called by:     ?"
    echo "# | Calls:         scriptname.pl"
    echo "# |"
    echo "# | Output:        /ux123/scripts/blddist.file10"
    echo "# |                "
    echo "# | Revisions:     Dvlpr Date     Version Comment/Change"
    echo "# |                ----- -------- ------- --------------------------------"
    echo "# |"
    echo "# +-----------------------------------------------------------------------"

    SQLPlus in a Here Document

    This is called a 'here document' - because it says "here is the text for your input". The redirection expressed as "<<EOF" says "take what follows as though I typed it at the keyboard, until you find a token to match EOF as the first token on a line". The token EOF has no special meaning - it's just a string of characters used as a marker to tell the 'here document' when the text input is completed.

    sqlplus <<EOF
          Select something
           from somewhere;
    EOF

    Important: the ending token must appear as the first characters on a line by itself.

    Thanks to Jim Benz of Pittsburgh for these notes.


    Monday, March 21, 2011

    Password Variables

    #! /usr/bin/ksh
    
    echo "#------------------------------------------------------------------------------"
    echo "# get passwords for the ftp and for sqlplus and assign to variables."
    echo "#------------------------------------------------------------------------------"
    
    export FTP_PASS='cat /ux123/dfact/xlt/scripts/ust_grp.password'
    
    export SQL_PASS='cat /ux123/dfact/xlt/scripts/xlt_ods_uat.password'
    
    echo "#------------------------------------------------------------------------------"
    echo "# start ftp from vax --i: turn off prompting    n: turn off login"
    echo "#------------------------------------------------------------------------------"
    
    ftp -in host1 <
    quote user ust_grp
    quote pass $FTP_PASS
    ...
    quit
    EOF
    
    echo "#------------------------------------------------------------------------------"
    echo "# In SQL+, ...
    echo "#------------------------------------------------------------------------------"
    
    sqlplus -s  $SQL_PASS << EOF
    .
    .
    exit;
    EOF

    Directory Listing

    Grep

    match any character.grep l..n filenamefinds 'lynn' or 'loan'
    match only if at the beginning of a line^grep ^day filenamefinds 'day into night'but not 'Some day'
    match only if at the end of the line$grep day$ filenamefinds 'One fine day'but not 'Monday is good'
    search for '.' or '^' or '$' in a file\grep \* filenamefinds '*****1.05'
    search for a set of names[]grep [dog,dil]bert filenamefinds 'dogbert' and 'dilbert'
    find all lines that start with an alphabetic character in upper or lower case^[]grep ^[A-Z,a-z] filename