IUBio

unix script files

Tim Bolling bollingt at ugene1.abbott.com
Tue Mar 29 14:07:05 EST 1994


> On/in VMS, it is very easy to write scripts or command files to change directory and to list the contents of the new directory.
> 
> When I try to write a unix script, it does it "behind the scenes".
> 
> for example if i want to go to a directory called data and list files:-
> 
> #a script to go to data and list
> cd jenkins/data
> ls 
> 
> It will go to directory data and list files, but at the end, i will be in the directory i started in. 
> 
> Any suggestions
Content-Length: 1002


Confounding when you start but you'll eventually prefer Unix over VMS (and 
then again, perhaps not).  I would presume that the reason that your new
changed directory doesn't "stick" is because you are executing your script
rather than "sourcing" it.  In other words, instead of running your script
by typing:

% myprogram

...you should run it by typing ...

% source myprogram

By sourcing, the changes effect your current shell.  If you execute (rather
than sourcing), the program automatically creates a daughter shell (subprocess),completes the script, kills the subprocess, and returns to the original, 
unaltered shell.

If you find the new script useful and would like to set up a shortcut to 
source it, you can make an alias.  For example, when you launch the "gcg"
command you are using the alias supplied by GCG...

  alias gcg 'source $GCGCOREROOT/genetics'

... to source the "genetics" file which sets up your environment for using
the GCG programs.

Tim Bolling
bollingt at ugene1.abbott.com




More information about the Info-gcg mailing list

Send comments to us at biosci-help [At] net.bio.net