[plug] script problem

Anthony J. Breeds-Taurima tony at cantech.net.au
Mon Aug 5 09:46:20 WST 2002


On Sun, 4 Aug 2002, Jon Miller wrote:

> 
> In my script the running of the functions seems to be the issue.  I have 2
> function that I run called
> -----------------------------------
> in_usr()
> create_usr()
> exit 0
> -----------------------------------
> 
> This is the error when I run the script
> /usrnput.sh: line 69: syntax error near unexpected token `create_usr('
> /usrnput.sh: line 69: `create_usr()'
> 
> My queston is do I run the function with or without the "()".  I've not

without IME

> program script before and this is my first attempt.  In other languages one
> would create teh functon as:
> function_name
> {
>     commands
> }
> 
> function_name()
> or 
> function_name(parameter) if you need to pass information.
> 
> Since I do not know how bash scripting functons are handled I'm at lost here
>   Also, if someone can recommend a good book (beginner - advanced) in bash
> scripting or a website that handles this.  I would greatly appreciate it.

Don't know if it's correct but:
---------
#!/bin/bash

DIRtree () {
DIR=$1
currentDIR=

for dir in `echo $DIR | tr '/' ' '`; do
        currentDIR=$currentDIR/$dir
        ls -ld $currentDIR
done

}

for i in $* ; do
        DIRtree $i
done
---------
/usr/src/linux/drivers/char/rio$ ddir `pwd`
drwxr-xr-x  25 root     root         4096 Oct 12  2001 /usr
drwxr-xr-x   9 root     root         4096 Jun 25 10:25 /usr/src
lrwxrwxrwx   1 root     root           17 Apr 30 13:34 /usr/src/linux -> linux-2.4.19-pre7
drwxr-xr-x  39 root     root         4096 Apr 30 13:34 /usr/src/linux/drivers
drwxr-xr-x  11 root     root         8192 Apr 30 13:41 /usr/src/linux/drivers/char
drwxr-xr-x   2 root     root         4096 Apr 30 13:34 /usr/src/linux/drivers/char/rio


Yours Tony

   Jan 22-25 2003           Linux.Conf.AU            http://linux.conf.au/
		  The Australian Linux Technical Conference!



More information about the plug mailing list