[Gllug] Why does this script not work?

robin.c.smith at bt.com robin.c.smith at bt.com
Mon Dec 10 10:37:58 UTC 2001


. ../cdscript.sh

This ( the little dot at the front although the syntax of this depends on
which shell you are running e.g. csh requires "souce ../cdscript.sh" ) will
run in the current shell - running the script you use starts a sub shell and
runs the commands
and then exits the shell leaving you where you were before.

Robin

-----Original Message-----
From: Colin Murphy [mailto:colin at ql4ever.demon.co.uk]
Sent: 10 December 2001 10:17
To: GLLUG
Subject: [Gllug] Why does this script not work?


I want a script that will change my current working directory to the 
path above, the same as 'cd ..'.


#!/bin/bash
pwd
cd ..
pwd

does what I would expect

[colin at second gllug]$ ../cdscript.sh
/home/colin/gllug
/home/colin

but doesn't 'set' the directory once the script exits.

How do I set my current directory to that set in the script.

-- 
Colin Murphy - colin at ql4ever.demon.co.uk
A man for all seasons, 'specially pepper.


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list