![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bourne Shell script - log for users loggin on and off | noodlesoup | Shell Programming and Scripting | 14 | 09-08-2006 07:30 PM |
| Bourne: How to invoke an alias from within a shell script | techshots | Shell Programming and Scripting | 2 | 06-03-2006 09:38 PM |
| Bourne Shell Script | dmhonor914 | UNIX for Dummies Questions & Answers | 2 | 12-10-2003 08:25 AM |
| bourne shell script | psrinivas | Shell Programming and Scripting | 2 | 12-06-2001 11:38 AM |
| Bourne shell script need help please ? | dezithug | UNIX for Advanced & Expert Users | 7 | 10-24-2001 10:59 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Dear Bourne Shell Expert,
I am trying to change the current working directory from within a Bourne Shell script. Simply enough i thought ! As I am sure you are well aware, Inside the script i echo `pwd` and it seems ok, but the shell spawns another shell to execute this and as such, when my script finishes it returns to the directory where i executed it in the first place. i execute the script from /opt/software and simply want to jump to a given directory. #!/usr/bin/sh echo " Now in `pwd` ### /opt/software cd /opt/skill echo " Now in `pwd` ### /opt/skill $PROMPT @ /opt/software > pwd returns /opt/software but i want it to be /opt/skill !!!!!! Please accept my mmost profound gratitude for your help support and valuable time in this matter. Best Regards, FMA |
| Forum Sponsor | ||
|
|
|
||||
|
|||
|
Dear all,
Im sorry to keep going on about this but i honestly do need to make a bourne shell script change the working directory of the current shell. Is there really no simple switch to enable this operation ??? I will add a quick example to illustrate : ################################################# #!/usr/bin/sh echo "1. Starting Project Script from = `pwd`" ### /home/fawqati echo "2. Please Enter Project Name : " ### vega project_name=readline echo " Entering Project /des/proj/$project_name " ### /des/proj/vega cd /des/proj/$project_name ################################################## After this executes i am still in /home/fawqati and NOT in /des/proj/<project_name> This is a real problem and i would be extremely gratefull for some help. Sincerly FMA |
|
||||
|
While I don't understand exactly why you need a script to issue a cd command, why just not create an alias? As in
Code:
alias 'cdv=cd /des/proj/$1' |
|
||||
|
Well, don't use readline to ask the user where he wants to go, then.
I have no idea what other things your huge modular script does, but whatever it does, it'll all go away once it exits - other than output redirected to a file, deleted/created files, and such - just like the cd command. The best I can give you is: 1.- create a user for each project, so users can su to it and be in the right directory, with the right environment, etc. 2.- Use expect. Expect has an "interact' command which gives the user control of the shell back within the script. |
||||
| Google The UNIX and Linux Forums |