Home » Infrastructure » Unix » Shell script (Unix)
Shell script [message #433269] Tue, 01 December 2009 02:55 Go to next message
prejib
Messages: 120
Registered: March 2009
Location: India
Senior Member
Hi,

I want to write an executable file in unix env to go to a particular path instead of always typing the long path cd /app/oracle/product/10.2.0/Db_1/scripts/prejib/sample.

I have tried with the below script in but not working . please help me


bash-3.00$ cat a.sh#!/bin/sh

mypath=/app/oracle/product/10.2.0/Db_1/scripts/pressy/sample
echo $mypath
cd $mypath

bash-3.00$ chmod +x a.sh
bash-3.00$ sh a.sh
/app/oracle/product/10.2.0/Db_1/scripts/pressy/sample
bash-3.00$ pwd
/app/oracle/product/10.2.0/Db_1/scripts/pressy
bash-3.00$

After executing the file a.sh, I am in the same path only
Re: Shell script [message #433276 is a reply to message #433269] Tue, 01 December 2009 03:21 Go to previous messageGo to next message
ThomasG
Messages: 3099
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Because you start a new shell.

When you run

sh a.sh


You start a new shell, and that new shell runs a.sh, and then closes again so you are again in your old shell where nothing has changed.

Try running just "a.sh" in your current shell.
Re: Shell script [message #433277 is a reply to message #433269] Tue, 01 December 2009 03:22 Go to previous message
Michel Cadot
Messages: 59118
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This question bears no real connection with Oracle.
Please find a more appropriate forum.
The topic is locked.

Regards
Michel
Previous Topic: Unable to use ORAENV_ASK in shell script
Next Topic: List of DB created
Goto Forum:
  


Current Time: Wed Sep 17 15:31:03 CDT 2014

Total time taken to generate the page: 0.08477 seconds