Re: Help me find 5 mistakes and than solution to thoes mistakes!

From: emarti1 (emarti1_at_sandia.gov)
Date: 08/17/04

  • Next message: netmask: "Re: Scan for wireless networks?"
    To: fedora-list@redhat.com
    Date: Tue, 17 Aug 2004 15:34:48 -0600
    
    

    It's really not that hard to get help.
    Ask someone at school CQU. Not here.
    Your not anonymous here.
    http://www.google.com/search?hl=en&ie=UTF-8&q=%22Damien+Clark%22+bash&btnG=Google+Search

    On Sun, 2004-08-15 at 18:01, Mr. Oberoi wrote:
    > 1:#!/bin/bash
    >
    >
    > 2:# Merge symlink files
    > 3:# Author: Damien Clark
    > 4:# Date: 8/Oct/2000
    > 5:# Purpose:
    > 6:#
    > 7:# Merge files from multiple directories into one directory by
    > linking
    > 8:# This script will create links to files from all of the filename
    > arguments
    > 9:# provided on commandline into the current directory, or from the
    > filename
    > 10:# arguments provided on stdin if no filenames provided on command
    > line.
    > 11:#
    > 12:# The script will check the following properties of the file,
    > before linking it:
    > 13:#
    > 14:# : make sure that each filename provided is actually a regular
    > file (not a
    > 15:# directory or symlink or device file)
    > 16:# : make sure that each file is readable
    > 17:# : make sure that the effective user running the script owns the
    > file,
    > 18:# or the effective group is the group owner ofthe file
    > 19:#
    > 20:# The script will also work properly on filenames with spaces. For
    > example:
    > 21:#
    > 22:# /home/clarkd/My Resume.doc
    > 23:#
    > 24:# Usage: $0 [-s] [-c] [ ...]
    > 25:#
    > 26:# -c option -> continue processing even if an error is detected on
    > a file.
    > 27:# Without this option, the script will stop if an error is
    > 28:# detected with a file.
    > 29:#
    > 30:# -s option -> create symbolic links instead of hard links (does
    > not check
    > 31:# if on same filesystem)
    > 32:#
    > 33:# If the script is provided file names as standard input, it can be
    > expressed
    > 34:# as shown in the example below:
    > 35:#
    > 36:# find ~ -type f -print| generatelinks.sh -s
    > 37:#
    > 38:# The command above will create symbolic links to the files found
    > within the
    > 39:# user's home directory, if the file properties match as above.
    > 40:#
    > 41:# If the script is run with filenames provided as command line
    > argument, as
    > 42:# shown in the example below:
    > 43:#
    > 44:# generatelinks.sh /home/clarkd/*.doc /home/clarkd/documents/*.doc
    > 45:#
    > 46:# without the ! -c option, then the script will ask to confirm
    > whether to continue
    > 47:# not to continue, or to continue for all.
    >
    >
    > 48:#Process each file and link it if it is okay.
    > 49:processfile
    > 50:{
    > 51: lnopts="$1"
    > 52: filename="$2"
    >
    >
    > 53: #file must be "normal file"
    > 54: if [ ! -f "$filename" ]
    > 55: then
    > 56: echo Not a normal file: $filename
    > 57: retval=1
    > 58: #must have "read perms"
    > 59: elif [ ! -r "$filename" ]
    > 60: then
    > 61: echo "No read permissions: $filename"
    > 62: retval=1
    > 63: #user must either effective owner the file or effective group
    > owner of the file
    > 64: elif [ ! -O "$filename" -o ! -G "$filename" ]
    > 65: then
    > 66: echo "No effective ownership or effective group ownership of file:
    > $filename"
    > 67: retval=1
    > 68: #Otherwise all is well, link the file to current directory using
    > existing name
    > 69: else
    > 70: ln $lnopts $filename
    > 71: retval=$?
    > 72: fi
    >
    >
    > 73: #Return the exit status code > 0 if a problem occured
    > 74: return $retval
    > 75:}
    >
    >
    > 76:# Initialise variables
    > 77:cont='N'
    > 78:lnopts=''
    >
    >
    > 79:# Process switches
    > 80:while test "$1" = '-c' '-o' "$1" = '-s'
    > 81:do
    > 82: if [ "$1" = '-c' ]
    > 83: then
    > 84: cont='Y'
    > 85: shift
    > 86: fi
    > 87: if [ "$1" = '-s' ]
    > 88: then
    > 89: lnopts='-s'
    > 90: shift
    > 91: fi
    > 92:done
    >
    >
    > 93:echo "Commencing generation of files
    >
    >
    > 94:if [$# -lt 1]
    >
    >
    > 95: while read filename
    > 96: do
    > 97: processfile "$lnopts" "$filename"
    > 98: result=$?
    >
    >
    > 99: test $result -ne 0 -a "$cont" != 'Y' -a "$cont" != 'y' || exit 1
    > 100: done
    >
    >
    > 101:else
    >
    >
    > 102: for filename in $*
    > 103: do
    > 104: processfile "$lnopts" "$filename"
    > 105: result=$?
    >
    >
    > 106: if [ $result -ne 0 -a "$cont" != 'Y' ]
    > 107: then
    > 108: echo -n "Error occurred. Continue (y/n/a)? "
    > 109: read $cont
    >
    >
    > 110: test "$cont" = 'n' -o "$cont" = 'N' && exit 1
    > 111: [ "$cont" = 'a' || "$cont" = 'A' ] && cont='Y'
    > 112: fi
    > 113: done
    >
    >
    > 114:fi
    >
    >
    > 115:echo "All files processed"
    >
    >
    >
    > Hints/Tips
    > There is only one mistake per line.
    > ALWAYS include the line number, the description of the problem and
    > your solution.
    >
    >
    >
    >
    > ______________________________________________________________________
    > Do you Yahoo!?
    > Y! Messenger - Communicate in real time. Download now.
    >
    > ______________________________________________________________________
    > --
    > fedora-list mailing list
    > fedora-list@redhat.com
    > To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list

    -- 
    fedora-list mailing list
    fedora-list@redhat.com
    To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
    

  • Next message: netmask: "Re: Scan for wireless networks?"

    Relevant Pages

    • Re: making a script
      ... batch command: executed successfully. ... Here's the script you need to batch process fuzzy borders. ... a filename that ends with ".scm". ... (script-fu-fuzzy-border image drawable color size blurt gran shadowt shadowp FALSE TRUE) ...
      (comp.graphics.apps.gimp)
    • Re: Taint mode & user supplied file names
      ... Would that be safe on all (or ... In your case lets say you run that script as a CGI script, ... In your case where you run the script from a command line you will still ... just means that what ever the -f $filename command read as returned true. ...
      (perl.beginners)
    • Re: Have perl increment a number that shows up before a delimiter
      ... > introduce this on the command line and have the script increment this ... There is no newline if you have entered the filename on the command ...
      (comp.lang.perl)
    • Re: @ARGV
      ... > has a .pl file with the following script, execute it at c: ... then take standard input from <STDIN>. ... print "Please enter filename to be copied\n"; ... Whatever they have entered on the command line becomes the value of $filename. ...
      (perl.beginners)
    • Re: Problems trying to configure Linux laptop to print to Windows XP shared printer
      ... map to guest = Never ... check password script = ... enumports command = ... ldap delete dn = No ...
      (comp.os.linux.setup)