LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to execute Source command in a shell script (https://www.linuxquestions.org/questions/linux-general-1/how-to-execute-source-command-in-a-shell-script-300046/)

UltraSoul 03-10-2005 12:00 PM

how to execute Source command in a shell script
 
My shell script named Test01 is as follows:

#!/bin/csh
source $HOME/csh.sol
source $HOME/setup.sol
set DISPLAY Dell01:0

$chmod 755 Test01

$echo $PATH
/usr/bin;$HOME/MyShell

$mv ./Test01 ~/MyShell
$Test01
$which icfb
icfb: command not found.

Problem1
if I source $HOME/csh.sol, the icfb command can be found.
It means my Test01 shell script did not excecute "source $HOME/csh.sol"
I wonder why it was not executed. And if execeuting the shell script by /bin/bash, i wonder if the source command will be executed.
How to fix the problem? Please help me.
Some useful http address about Shell script is appreciated.

Dark_Helmet 03-10-2005 01:27 PM

The script did source the file. :)

That's not the problem though. It's a side-effect of processes. When you execute a shell script, you create a new process for the script to run in. Any changes to the environment your script makes are isolated to the shell script's process. Those changes are not, and cannot be pushed back up to the original shell.

The only "fix" for this is to source the script rather than execute it.

Poki 09-23-2010 10:13 AM

just wanted to thank you i was just working on the same issue.. source from the script and not seeing results after script completed

Poki 09-23-2010 10:13 AM

Quote:

Originally Posted by Dark_Helmet (Post 1522027)
The script did source the file. :)

That's not the problem though. It's a side-effect of processes. When you execute a shell script, you create a new process for the script to run in. Any changes to the environment your script makes are isolated to the shell script's process. Those changes are not, and cannot be pushed back up to the original shell.

The only "fix" for this is to source the script rather than execute it.

just wanted to thank you i was just working on the same issue.. source from the script and not seeing results after script completed


All times are GMT -5. The time now is 01:17 AM.