1830230 Members
2330 Online
109999 Solutions
New Discussion

Basic Script Help

 
L. Younes
Occasional Advisor

Basic Script Help

Hi everyone;

I've been testing the following basic script on a HP 11.11 system (script name : test) :

#!/usr/bin/bash

. ./.bashrc

echo FINISH


when I launch ./test the scripts executes with no problem.

When I launch it like this ./test& the script hangs
in the background ( FINISH doen't get displayed) the command "jobs" reports the following: bash$ jobs
[1]+ Stopped ./test

when normally it should display "Done" instead of "Stopped". the hang is definitly occuring on the . ./.bashrc

On another HP 11.11 system it finishes either way I launch it. On Solaris I have no problems also.

in a script could . ./.bashrc be replaced with ./.bashrc ?

In general, if I have a script that sets some environment variables is it necessary to source the script when it's called in another script ?

Thanks for your help


1 REPLY 1
John Palmer
Honored Contributor

Re: Basic Script Help

What's in the sub-script .bashrc? Something in there is causing your hang.

>>in a script could . ./.bashrc be replaced with ./.bashrc ?

It depends... The subtle difference is that . ./.bashrc runs within your current shell so any environment changes (variables etc) will remain when it finishes. ./.bashrc runs as a seperate child process so will not change the environment in your current shell at all.

Regards,
John