Home » Infrastructure » Unix » Shell script (Unix)
Shell script [message #433269] Tue, 01 December 2009 02:55 Go to next message
prejib
Messages: 126
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: 3211
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: 68625
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: Fri Mar 29 02:11:45 CDT 2024