problem switching to directory using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem switching to directory using shell script
# 1  
Old 02-02-2011
problem switching to directory using shell script

Hi,

I have an issue with switching to other directory through shell script. I have used

Code:
 cd /Music"

but that doesn't help me. Then I have also tried using
Code:
alias proj 'Music'
alias

then I get the error permission denied but i set the chmod 777 Music. I am using cShell for my scripting. I also tried export proj=Music but not use. can any one please help me with this issue.

Thank You,

Baluk
# 2  
Old 02-02-2011
Code:
source script

# 3  
Old 02-02-2011
I suppose it depends what the cd in the script is for. If it is intended that this sets up the user environment and leaves them (or the calling script) in the correct directory, then you will need to call it in to overwrite your current environment. For many shells (sh, bash, ksh, etc.) this is done as follows:-
Code:
. my_environemt_script


For a csh call, it is:
Code:
source my_environment_script


You are correct that you need the execute permission on a directory to cd to it, so if I have missed the point, please let me know.



Robin
Liverpool/Blackburn
UK



P.S. You don't have any 3rd party security software installed do you? Some of the very good ones will manage file/directory access as though they were assets to be protected. You would need a specific rule to allow you to do this. Can you supply the simplest example with the error and an ls -ld of the directory?


Thanks,
Robin
# 4  
Old 02-02-2011
When you are in the directory called Music , please post the output from the unix command "pwd" to display the tree to the current directory:
Code:
pwd

Please then do the same for the directory containing the script and we should be able to work out how to get from one directory to the other.


Btw. If "Music" is just subdirectory, did you try:
Code:
cd Music

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. UNIX for Advanced & Expert Users

Problem with shell script while spaces encountered in directory names

Hi, I am having issues with the jar -tf command when I put in the shell script. The command runs fine from the command line as shown below. # jar -tf "./VirtualBox Dropped Files/2016-04-17T20:58:49.129139000Z/hive-exec-0.8.1.jar" But when I put in a shell script(shown below) and the... (10 Replies)
Discussion started by: vinoo128
10 Replies

3. Shell Programming and Scripting

Moving Files one directory to another directory shell script

Hi, Could you please assist how to move the gz files which are older than the 90 days from one folder to another folder ,before that it need to check the file system named "nfs" if size is less than 90 or not. If size is above 90 then it shouldn't perform file move and exit the script throwing... (4 Replies)
Discussion started by: venkat918
4 Replies

4. Shell Programming and Scripting

Switching server in UNIX via shell script (SSH )

Requirement: I am writing a shell script which take some file from say Server1 and I have to execute some command on Server2 then I have to manipulate the data and based on that I have to produce report. Problem:I can schedule the shell script on only one server (Server1 or Server2) So, In the... (3 Replies)
Discussion started by: raks2301
3 Replies

5. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

6. Shell Programming and Scripting

Switching user inside a shell script doesn't seem to work

Linux version : Oracle Linux 6.4 Shell : Bash The following script will be run as root. During the execution, it should switch to oracle user and execute few commands. After googling and searching within unix.com , I came up with the following syntax ## Enclosing all commands in double... (7 Replies)
Discussion started by: John K
7 Replies

7. UNIX for Dummies Questions & Answers

Switching user inside a shell script

Dear All, I want to switch a user inside a shell script.My current user say x and user y to whom i want to switch both have login on the same server,the one on which i want to execute my script on. "I want to do something like this su - y Password should be provided in the script itself.And... (6 Replies)
Discussion started by: navjotmannan
6 Replies

8. Shell Programming and Scripting

switching to another user in shell script...

Hi, I have a shell script in which I need to switch to another user and execute some commands and then come back to the original user. To make it more clear - I have to log in as user root then 'su' to jag - execute a script called backup.sh and then logout and come back to root again.. ... (1 Reply)
Discussion started by: bjagadeesh
1 Replies

9. Shell Programming and Scripting

Switching workspaces thru shell scr.(Solaris)

Using Solaris CDE environment and want to write a shell script (pref. Korn) which can: Upon invokation opens a dtterm new window (no problems, here, i.e. on how to open one) The new dtterm should be moved by the script to another workspace (consider no one changed the default Solaris naming... (3 Replies)
Discussion started by: baivab
3 Replies

10. UNIX for Dummies Questions & Answers

Mac OS keeps switching between shell types

Whenever I relaunch my terminal application on Mac OS 10.4.6, the shell changes to something different. E.g. I used to work in "sh" and then relaunch, I am suddenly in "bash" mode and none of the most basic commands work anymore. Why can't the unix community agree on one single type of shell?? As... (1 Reply)
Discussion started by: PixelLover
1 Replies
Login or Register to Ask a Question