public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* bash script does't work.
@ 2003-11-02 17:24 Seiji Yoneda
  2003-11-02 17:36 ` Pierre-Philippe Coupard
  0 siblings, 1 reply; 3+ messages in thread
From: Seiji Yoneda @ 2003-11-02 17:24 UTC (permalink / raw)
  To: cygwin at cygwin dot com

Hi,

I'm using bash 2.05a.0(2) on win2k pro and I'm running into problems
that the bash script doesn't work as I expected.

My bash script is as follows,  

<---------------- from here the script (ora8i.sh) start
#!/usr/bin/bash

ORA_HOME='/c/oracle/ora817'
export ORA_HOME
PATH=${ORA_HOME}/bin:${PATH}
export PATH
printenv PATH 
<---------------- here the script end

When execute these commands step by step, PATH environment variable
changes. But execute above bash script, PATH environment variable doesn't
change.
What's wrong ? If someone has some idea about this problem, please help me!

$ printenv ORA_HOME   <---------------- Before execution of script
    <----------- Before execution of script, ORA_HOME has nothing.
$ printenv PATH
/usr/local/pgsql/bin:/usr/local/pgsql/lib:/usr/local/bin:/usr/bin:/bin:/c/j2sdk1
.4.2_02/bin:/c/WINNT/system32:/c/WINNT:/c/WINNT/System32/Wbem

$ ora8i.sh        <---------------- Execute this script
/c/oracle/ora817/bin:/usr/local/pgsql/bin:/usr/local/pgsql/lib:/usr/local/bin:/u
sr/bin:/bin:/c/j2sdk1.4.2_02/bin:/c/WINNT/system32:/c/WINNT:/c/WINNT/System32/Wb
em

$ printenv ORA_HOME   <---------------- After execution of script
    <----------- After execution, ORA_HOME has nothing !!
$ printenv PATH   <---------------- After execution, PATH does't change!!
/usr/local/pgsql/bin:/usr/local/pgsql/lib:/usr/local/bin:/usr/bin:/bin:/c/j2sdk1
.4.2_02/bin:/c/WINNT/system32:/c/WINNT:/c/WINNT/System32/Wbem

------------------------------------
Seiji Yoneda <s-yoneda@spn1.speednet.ne.jp>
------------------------------------



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bash script does't work.
  2003-11-02 17:24 bash script does't work Seiji Yoneda
@ 2003-11-02 17:36 ` Pierre-Philippe Coupard
  2003-11-03 12:15   ` Hannu E K Nevalainen
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre-Philippe Coupard @ 2003-11-02 17:36 UTC (permalink / raw)
  To: cygwin

Seiji Yoneda wrote:
> $ ora8i.sh        <---------------- Execute this script

--8<--8<--

> $ printenv ORA_HOME   <---------------- After execution of script
>     <----------- After execution, ORA_HOME has nothing !!
> $ printenv PATH   <---------------- After execution, PATH does't change!!

This isn't a cygwin issue.

Because the PATH you change in your script is a variable that's local to 
the shell running it. Because you call your script as a binary, another 
shell is spawned (the #!/bin/sh basically tells the kernel to use 
/bin/sh as the interpreter).

Try running you script as ". ora8i.sh" and it'll work : the "." is a 
shell command that means "execute this shell script" (in the current shell).

-- 
Pierre-Philippe Coupard <pcoupard@easyconnect.fr>
Software Engineer
--
Does the name Pavlov ring a bell?


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: bash script does't work.
  2003-11-02 17:36 ` Pierre-Philippe Coupard
@ 2003-11-03 12:15   ` Hannu E K Nevalainen
  0 siblings, 0 replies; 3+ messages in thread
From: Hannu E K Nevalainen @ 2003-11-03 12:15 UTC (permalink / raw)
  To: cygwin

> From: Pierre-Philippe Coupard
> Sent: Sunday, November 02, 2003 6:36 PM

> Seiji Yoneda wrote:
> > $ ora8i.sh        <---------------- Execute this script
> 
> --8<--8<--
> 
> > $ printenv ORA_HOME   <---------------- After execution of script
> >     <----------- After execution, ORA_HOME has nothing !!
> > $ printenv PATH   <---------------- After execution, PATH 
> does't change!!
> 
> This isn't a cygwin issue.
> 
> Because the PATH you change in your script is a variable that's local to 
> the shell running it. Because you call your script as a binary, another 
> shell is spawned (the #!/bin/sh basically tells the kernel to use 
> /bin/sh as the interpreter).
> 
> Try running you script as ". ora8i.sh" and it'll work : the "." is a 
> shell command that means "execute this shell script" (in the 
> current shell).

 "." is shortcut for "source"

Typing this, and reading the text that appears,
should help explain things:

$ man bash
/ENVIRONMENT

$ help source

$ man bash
/BUILTIN COMMANDS$

IMO there is one big shortcoming with "source" - it can't be piped into.

/Hannu E K Nevalainen, B.Sc. EE - 59?16.37'N, 17?12.60'E
-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-11-03 12:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-02 17:24 bash script does't work Seiji Yoneda
2003-11-02 17:36 ` Pierre-Philippe Coupard
2003-11-03 12:15   ` Hannu E K Nevalainen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).