943,990 Members | Top Members by Rank

Ad:
Jan 31st, 2006
0

Need scripting expert help

Expand Post »
Hi Can anyone help me with this. Im new to doing scripts. Thanks

I am writing a simple script to cd to another directory. But the directory does not change after running the script. How can i make the directory change after running the script?



operator@tiger013s% pwd

/export/home/tiger013s/operator

operator@tiger013s% more sample

#!/bin/csh

cd /home/local_summary

operator@tiger013s% sample

operator@tiger013s% pwd

/export/home/tiger013s/operator -> i want to be in /home/local_summary
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MikeDirnt is offline Offline
1 posts
since Jan 2006
Feb 1st, 2006
0

Re: Need scripting expert help

Hi,

Remove "#!/bin/csh" from your script. This instructs the shell to begin a new shell session to execute your script. This is why it does not change your 'current' directory. It is the 'new' shell session which changes directory and then that session exits when the script is done.

Kate
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
Kate Albany is offline Offline
71 posts
since Jun 2005
Feb 1st, 2006
0

Re: Need scripting expert help

And. You have to source the script. It may or may not run in a subshell (another process) with
. myfscript.sh

note the leading dot - in linux there is the source command in bash which does the same thing.
Reputation Points: 62
Solved Threads: 10
Junior Poster
jim mcnamara is offline Offline
179 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: Network access ksh
Next Thread in Shell Scripting Forum Timeline: Creating shell script that use snort





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC