0

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

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by jim mcnamara
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

0

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

[b].[/b] myfscript.sh

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.