LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 03-10-2005, 01:00 PM   #1
UltraSoul
Member
 
Registered: Dec 2004
Location: Japan
Distribution: REDHAT9.0, Mandrake10.1
Posts: 404

Rep: Reputation: 31
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.
 
Old 03-10-2005, 02:27 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
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.
 
1 members found this post helpful.
Old 09-23-2010, 11:13 AM   #3
Poki
LQ Newbie
 
Registered: May 2009
Posts: 21

Rep: Reputation: 0
just wanted to thank you i was just working on the same issue.. source from the script and not seeing results after script completed
 
Old 09-23-2010, 11:13 AM   #4
Poki
LQ Newbie
 
Registered: May 2009
Posts: 21

Rep: Reputation: 0
Quote:
Originally Posted by Dark_Helmet View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
execute shell script in KDE Lotharster Linux - Newbie 1 11-21-2005 07:02 PM
How to execute a command line in a shell script orgazmo Programming 5 05-09-2005 10:16 AM
auto execute shell script ykirankumar Linux - Software 3 09-22-2004 08:23 AM
shell script won't execute brandnewbie Linux - Newbie 7 08-10-2004 02:30 PM
shell script how to execute x2000koh Programming 6 07-29-2003 05:20 PM


All times are GMT -5. The time now is 12:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration