[plug] calling a script within a script
Timothy White
weirdit at gmail.com
Thu Dec 8 22:20:09 WST 2005
On 12/8/05, Richard Meyer <meyerri at westnet.com.au> wrote:
> On Fri, 2005-12-09 at 11:22 +0800, Jon Miller wrote:
> > Like to know how do I call a script (backup1-functions) within a script (backup1.sh). Within the backup1-functions script there are other functions.
> >
> > Tried the following
> > . backup1-functions
> > ./backup1-functions
> > . ./backup1-functions
> > I get the same response:
> > # ./backup1.sh
> > ./backup1.sh: line 21: ./backup1-functions: No such file or directory
> > ./backup1.sh: line 24: tar_backup: command not found
> > ./backup1.sh: line 27: tar_verify: command not found
> >
> > Thanks
>
> Is it a separate script? If so, try ~/backup1-functions, or give the
> full path. Who knows, it MAY work ;-)
Providing the path, should just work. (as in full path, or ./ as you
have tried.)
Of course, this is assuming that the script is a (ba)sh script, or is
an executable file with the correct handlers so that it can be run.
I'm not 100% sure if it needs to have the execute bit sit, if it's a
bash script but if it doesn't the source command will still work.
Straight from the bash man pages. (with minimal editing so wrap
shouldn't effect it)
source filename [arguments]
Read and execute commands from filename in the current shell
environment and return the exit status of the last command exe‐
cuted from filename. If filename does not contain a slash, file
names in PATH are used to find the directory containing file‐
name. The file searched for in PATH need not be executable.
When bash is not in posix mode, the current directory is
searched if no file is found in PATH. If the sourcepath option
to the shopt builtin command is turned off, the PATH is not
searched. If any arguments are supplied, they become the posi‐
tional parameters when filename is executed. Otherwise the
positional parameters are unchanged. The return status is the
status of the last command exited within the script (0 if no
commands are executed), and false if filename is not found or
cannot be read.
Tim
--
Linux Counter user #273956
More information about the plug
mailing list