cd in scripts

cd in scripts

Post by Bartosz Klim » Thu, 31 Oct 1996 04:00:00



I've just been trying to write a script that changes the current
directory (not only):

#!/bin/tcsh
.....
cd dir1
.....

It doesn't work because it is interpreted by another copy of tcsh,
and when the script terminates, the copy of tcsh terminates too, and
the current directory remains unchanged. I have no idea what to do
about this. Can you help me? Of course, I'm not interested in aliases or
something like "> source script".

Bartosz Klimek

 
 
 

cd in scripts

Post by Icarus Spar » Thu, 31 Oct 1996 04:00:00




>I've just been trying to write a script that changes the current
>directory (not only):

>#!/bin/tcsh
>.....
>cd dir1
>.....

>It doesn't work because it is interpreted by another copy of tcsh,
>and when the script terminates, the copy of tcsh terminates too, and
>the current directory remains unchanged. I have no idea what to do
>about this. Can you help me? Of course, I'm not interested in aliases or
>something like "> source script".

"I am not interested in something that works, only something that fits
my preconceptions".

The answer is to write a program which opens up the kernel memory, and
plays fast and loose with the status of other programs. Patch 'cd' in 'tcsh'
to call this program.

Otherwise accept that using 'source' or 'alias' is the correct way to do it.
Icarus

 
 
 

cd in scripts

Post by Stanislaw Streln » Fri, 01 Nov 1996 04:00:00


: I've just been trying to write a script that changes the current
: directory (not only):

: #!/bin/tcsh
: .....
: cd dir1
: .....

: It doesn't work because it is interpreted by another copy of tcsh,
: and when the script terminates, the copy of tcsh terminates too, and
: the current directory remains unchanged. I have no idea what to do
: about this. Can you help me? Of course, I'm not interested in aliases or
: something like "> source script".

  Well, of course, if you aren't interested in the only ways it can be done,
you have really serious problem. Because you CAN'T change parent's directory
from within the script.

--

   St. Strelnik

 
 
 

cd in scripts

Post by Dave Bro » Fri, 01 Nov 1996 04:00:00



: I've just been trying to write a script that changes the current
: directory (not only):

Use aliases or say ". script".

[...]
: Of course, I'm not interested in aliases or
: something like "> source script".

Oh, well, in that case, it can't be done at all.  Tough.

--Dave
--
WARNING: sending me junk-email will be interpreted as granting permission to
bomb your offices and machine-gun your children. (10 in 4 days, 3 in 1 hour)
(thanks, Simon!)

 
 
 

cd in scripts

Post by David Weintra » Tue, 05 Nov 1996 04:00:00



> I've just been trying to write a script that changes the current
> directory (not only):

> #!/bin/tcsh
> .....
> cd dir1
> .....

> It doesn't work because it is interpreted by another copy of tcsh,
> and when the script terminates, the copy of tcsh terminates too, and
> the current directory remains unchanged. I have no idea what to do
> about this. Can you help me? Of course, I'm not interested in aliases or
> something like "> source script".

When you run a shell script in ANY shell, you're copying in your
current environment into a child process. When you leave your child
process, you loose all of your environment changes, and you're back
where you started. No way around that. This includes setting
environment variables, shell settings, etc. The only way around this
problem is to run the shell script in the current environment.

Since you specifically said you don't want to source in the file, there
is no way around.

--

Deutsche Morgen Grenfell                Phone: 212-469-3416
Business Technology Systems             Fax:   212-469-6220

 
 
 

1. Script to eject CD-ROM drive and ask for appropriate CD??

I download lots of large movie files from P2P networks, which I place
on CD-Rs.  I then remove the movie files from my computer, and leave a
reference to the CD.  I would like to create a script that will do the
following when I click on it / execute it:

(1) Eject te CD-ROM drive

(2) Ask me to "Insert the appropriate CD-ROM (i.e., Please insert CD
labelled "FINAL DESTINATION") then press any key"

(3) Wait to proceed until I press a button

(4) If the CD-ROM drive is out, retract it

(5) Check the MD5SUM of the movie file on the CD-R and compare it to
the known MD5SUM of the movie file (which I would have determined
before making the CD) and then play the CD using the appropriate
program (i.e., a DivX player).  Alternatively, if the improper CD was
inserted, it would return to step (1).

2. Sol2.4, SPARCprinter II, XRam memory error???

3. Execute a sh script under perl and sh: sh script; perl script?

4. Oracle

5. In search of Solaris 2.5 Netscape Navigator 3.0 plug ins

6. how to make a file server ?

7. Need HELP to Log User Log-ins form the internet

8. What do panic messages mean?

9. Suse 7.0; Yast2, kinternet, rc.dialout und ich komme nicht ins Internet

10. Netscape plug-ins on AIX 4

11. what is a INS server?

12. dial ins

13. plug-ins netscape