[sf-lug] Need help with an Linux assignment script

jim jim at well.com
Tue Apr 29 07:32:43 PDT 2008


here's a pointer to a vi quick sheet: 
http://www.sf-lug.com/How2vi.html 

mistake below, s.b. >> not > ## look for this comment down there 



On Tue, 2008-04-29 at 00:34 -0700, Timothy Wang wrote:
> Sorry Jim:
> this is the exact instructions for the assignment
> 
> http://fog.ccsf.cc.ca.us/~gboyd/cs160b/asmt02.pdf
> 
> --- On Mon, 4/28/08, jim <jim at well.com> wrote:
> 
> > From: jim <jim at well.com>
> > Subject: Re: [sf-lug] Need help with an Linux assignment script
> > To: timothyjwang at yahoo.com
> > Cc: "SF-LUG ML" <sf-lug at linuxmafia.com>
> > Date: Monday, April 28, 2008, 9:05 PM
> > i looked at the link and can find nothing 
> > that is tagged asmt02. please provide a link 
> > to the exact assignment so we don't have to 
> > hunt around. 
> > 
> >    what error messages or failure symptoms do 
> > you get when you run this? 
> > 
> >    assuming the filename is  asmt02.sh  you 
> > can  
> > head -20 asmt02.sh > a2-try.sh  
> > and 
> > vi a2-try.sh  
> > so's to prune what you've got in your  a2-try.sh  
> > file so that it looks like it'll work.  
> > chmod 755 a2-try.sh  
> > and then run it and see if it works. 
> >    if so, then essentially 
> > head -30 asmt02.sh | tail -10 > a2-try.sh ## my mistake, s.b. >> a2-try.sh 
> > vi a2-try.sh 
> > in other words add a bit more to it and vi 
> > it and run it and keep doing so until it 
> > runs into a wall. 
> > 
> >    verify your  if elif else fi blocks  and 
> >  quotes and make sure that all  $  are 
> > correctly placed (and not missing). 
> >    you'll probably find the error yourself, 
> > but if not, provide a direct link to the 
> > assignment and provide a description of 
> > failure and we'll (at least i'll) try again. 
> > 
> > 
> > 
> > On Mon, 2008-04-28 at 20:07 -0700, Timothy Wang wrote:
> > > I am doing an assignment in City College CS160b and
> > was having difficulty 
> > > understanding why it is not working. The assignment is
> > posted on 
> > > 
> > > http://fog.ccsf.cc.ca.us/~gboyd/
> > > 
> > > under cs 160b asmt02
> > > 
> > > twang03 at hills:~ $ vi chk
> > > 
> > > #!/bin/bash
> > > #1st argument if filepath exists, output in readable
> > sentences
> > > 
> > > 
> > > 
> > > 
> > > if [ $# -lt 2 ]; then
> > >     echo "chk: need -f or -u file or user"
> > >&2
> > >     exit 1
> > > fi
> > > 
> > > if [ ! "$1" = -f ] && [ !
> > "$1" = -u ]; then
> > >     echo "chk need -f or -u plus file or
> > user" >&2
> > >     exit 1
> > > fi
> > > # =====    ============================
> > > if [ "$1" = -f ]; then
> > > 
> > >     if [ -h "$fname" ]; then
> > >             echo "fname" is a path to a
> > symbolic link
> > > 
> > >     elif [ -d "$fname" ]; then
> > >         echo "$fname" is a path to a
> > directory
> > > 
> > >     elif [ -f "$fname" ]; then
> > >         echo "fname" is a path to a regular
> > file
> > > 
> > >     elif [ ! -d " $fname" ] && [ !
> > -f "$fname" ] && [ ! -h
> > "$fname" ];then
> > >         echo "$fname" is a path to an
> > unknown filetype.
> > >     fi
> > > 
> > >     if [ -r "$fname" ] && [ ! -w
> > "$fname" ] && [ ! -x "$fname"
> > ]; then
> > >         echo "$fname" is readable.
> > >     else
> > >         echo "$fname" is not readable.
> > >     fi
> > > 
> > >     if [ -w "$fname" ] && [ ! -w
> > "$fname" ] && [ ! -x "$fname"
> > ]; then
> > >         echo "$fname" is writable
> > >     else
> > >         echo "$fname" is not writable
> > >     fi
> > > 
> > >     if [ -x "$fname" ] && [ ! -w
> > "$fname" ] && [ ! -x "$fname"
> > ]; then
> > >         echo "$fname" is executable
> > >     else
> > >         echo "$fname" is not executable
> > >     fi
> > > fi
> > > # ==================================================
> > > 
> > > if [ "$1" = -u ]; then
> > >     if $(! cat /etc/passwd | grep "^$2:"
> > > /dev/null)
> > >     then
> > >         echo error found
> > > fi
> > >     login="$2"
> > >     name="$(finger -m "$login" | grep
> > 'real life' | cut -d':' -f3 | tail
> > -n1)"
> > > 
> > >     logrec="$(finger -m "$login" | grep
> > 'Last login' | cut -d' ' -f3)"
> > >     whom="$(who | grep "$login")"
> > >     hmdir="$(finger -m "$login" | grep
> > 'Directory: ' | cut -d' ' -f2)"
> > > 
> > >     if "$("name" =
> > "???")"; then
> > >         echo "$login doesn\'t exist on
> > this system"
> > >     else
> > >         if [ -n "$who" ]; then
> > >             echo "$login is currently logged into
> > the system"
> > >         else
> > >             echo "$login"\'s last
> > login was "$logrec"
> > >         fi
> > > 
> > >         echo "$login"\'s real name
> > is "$name"
> > >         echo "$login"\'s home
> > directory is located at "$hmdir"
> > >     fi
> > > fi
> > > 
> > >                                                       
> >                                                             
> >                        77,0-1        96%
> > > 
> > > 
> > >      
> > ____________________________________________________________________________________
> > > Be a better friend, newshound, and 
> > > know-it-all with Yahoo! Mobile.  Try it now. 
> > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> > > 
> > > _______________________________________________
> > > sf-lug mailing list
> > > sf-lug at linuxmafia.com
> > > http://linuxmafia.com/mailman/listinfo/sf-lug
> > >
> 
> 
>       ____________________________________________________________________________________
> Be a better friend, newshound, and 
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> 





More information about the sf-lug mailing list