954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need scripting expert help

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

MikeDirnt
Newbie Poster
1 post since Jan 2006
Reputation Points: 10
Solved Threads: 0
 

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

Kate Albany
Junior Poster in Training
71 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

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

<strong>.</strong> myfscript.sh


note the leading dot - in linux there is the source command in bash which does the same thing.

jim mcnamara
Junior Poster
180 posts since May 2004
Reputation Points: 62
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You