[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell script function problems



phillinux wrote:
        At 11:33 PM 2/8/2008, you wrote:
phillinux <phillinux@nyc.rr.com>:
>
>  I'm trying to write a bash shell script to create user accounts that
>  calls 2 functions. I can't call these functions from the script or

Why?

>  the command line.

Why?

>  The set command seems to show the loaded script in
>  the shell (loaded with . FunctionName at command line) with other
>  environmental variables. ALSO: The type command does not recognize
>  the function.

[Eyes roll up in head.]  What!?!

>  The script and functions work on my laptop running Fedora (with one
>  small glitch). Is there something I can do to my Debian server to get
>  functions recognized??

This is not rocket science.  Once they're sourced [but you can't
source them?!?], they're callable.  They're in the environment ready
to be used.

How is it you're having a problem with this?  What is it, really,
you're trying to do?


Why am creati ng a script to create users???
Answer:
I'm a teacher managing the school server. Teachers give edited MS excel files of students to be added to the system. The script reads the class lists and loops through account creation

Why a function???
Answer:
I was told only a function could be called recursively. The function is called recursively to append a number to the user name when duplicate user names are found on the system.

What do you mean by "sourced"?? Is that loading them into the environment??
That's what I'm talking about. on my laptop it works. on the server it doesn't I don't understand why. how do you "source" a function??


You can source files either by:

. /file/to/be/sourced
or
source /file/to/be/sourced

either method should work just fine.

If this script is the only one that will be using these functions, why not just include them into the script itself?

But whats failing in your script? There are some differences in how debian and fedora add users. Have you ran your script with the -x to debug it? That may help finding out where your script is failing.

Jeff




Reply to: