Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Shell script function problems

From: William Pursell <bill.pursell(at)gmail.com>
Date: Sat Feb 09 2008 - 07:36:53 EST


phillinux wrote:
>
> 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 the
> command line. 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.
>
>
> 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??
>

 From some other comments in the thread, it sounds like you are trying to do something like the following:

>
> $ cat foo
>
> g()
> {
> printf 'in g\n'
> }
> $ cat bar
> #!/bin/sh
>
> g
> $ . foo
> $ ./bar # won't work since bar doesn't source foo
> ./bar: line 3: g: command not found
> $ cat baz
> #!/bin/sh
>
> . foo
> g
> $ ./baz
> in g

If you source the file with the function definitions, it makes the functions available in the current shell, but not in subshells that you may invoke.

-- 
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Received on Sat Feb 9 07:28:29 2008

This archive was generated by hypermail 2.1.8 : Tue Mar 11 2008 - 15:18:20 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library