Change Directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change Directory
# 1  
Old 12-26-2013
Change Directory

Hi All,

There is a code like below in my script

Code:
###############################################
###Create Directories and Sub-Directories
###############################################

dpdir=DP_FROM_${from}_TO_${to}
mkdir $dpdir
cd $dpdir
mkdir AWQM WFCONTROLLER PROVCO PRISM

####################################################
###Datapump --- Export and Import of Schema Objects
####################################################
cd $dpdir/AWQM

Its ( cd $dpdir/AWQM) giving error No such file or directory. I can assign "pwd" to variable and then change directory will work i believe. Is there any other way i can achieve this without assign any directory path?. Please suggest.

Thanks,
Mani

Last edited by Don Cragun; 12-26-2013 at 08:40 PM.. Reason: Second guess at where CODE tags should have been placed.
# 2  
Old 12-26-2013
Quote:
Originally Posted by pvmanikandan
Hi All,

There is a code like below in my script

Code:
###############################################
###Create Directories and Sub-Directories
###############################################

dpdir=DP_FROM_${from}_TO_${to}
mkdir $dpdir
cd $dpdir
mkdir AWQM WFCONTROLLER PROVCO PRISM

####################################################
###Datapump --- Export and Import of Schema Objects
####################################################

cd $dpdir/AWQM

Its ( cd $dpdir/AWQM) giving error No such file or directory. I can assign "pwd" to variable and then change directory will work i believe. Is there any other way i can achieve this without assign any directory path?. Please suggest.

Thanks,
Mani
The 1st cd marked in red above already moved the script into the directory named by the expansion of the dpdir shell variable. The 2nd cd marked in red above will work if and only if dpdir expands to an absolute pathname. But, the definition of dpdir in this script is a relative pathname.

If you change the 2nd cd to just:
Code:
cd AWQM

it should get you to where I would guess it was trying to go.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change directory shell

#!/bin/bash echo -n "Enter number of sanger patients : "; read id perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo")' < file.txt I have the above script... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. UNIX for Dummies Questions & Answers

Change permission to a directory

Hi, How do i change the permission to read/write to a windows directory? (1 Reply)
Discussion started by: lg123
1 Replies

3. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

4. UNIX for Dummies Questions & Answers

How to change database directory to another directory?

Hi, I Installed mysql on my CentOS 6.2 Server. But when I tried to change the location of /var/lib/mysql to another directory. I can't start the mysql. Below is what I've done yum install mysql mysql-server mysql-devel mkdir /path/to/new/ cp -R /var/lib/mysql /path/to/new chown -R... (1 Reply)
Discussion started by: ganitolngyundre
1 Replies

5. AIX

disallow change directory

Dear all expects, I have a security problem that I would like to resolve. I need to create a user ID in my AIX 5.3 environment and to point the login to a specific directory for FTP purposes. There is only 2 directories that I can allow the user ID to perform read/write. I would like to prevent... (2 Replies)
Discussion started by: kwliew999
2 Replies

6. Shell Programming and Scripting

change directory if available

I have a simple shell script that prompts the user to enter a directory to navigate to. What i want it to do and i don't know how to do this is if the directory is invalid automatically navigate to the home directory. echo "enter a directory to navigate to:" read directory cd $directory... (6 Replies)
Discussion started by: icelated
6 Replies

7. UNIX for Dummies Questions & Answers

Filenames change in a directory

Hi I have abc_ahb_one.v abc_ahb_two.v abc_ahb_three.v ........l like this -----upto abc_ahb_ninety.v in some directory. I need to change those file names to like below. ... (5 Replies)
Discussion started by: praneethk
5 Replies

8. UNIX for Dummies Questions & Answers

Change Directory

I have a directory that is existing under my root dir of the FTP server. The DIR name is 'Software Patch'. I want to move in to that DIR to download some patches. But, when I issued a command 'cd SOftware Patch', the system said that it cannot find the dir 'Software'. I tried all possible ways like... (2 Replies)
Discussion started by: vskr72
2 Replies

9. Shell Programming and Scripting

change directory

hi, Iam in directory A. I run a script from there. inside the script i have a command cd B. When i come out of the script directory is A only. Even when i come out scrip i want the directory to be B How to achieve (2 Replies)
Discussion started by: mkan
2 Replies

10. Shell Programming and Scripting

change directory

Hi all, I'm trying to wirte a small shell script in Linux. My script has the flow like, cmd1 cmd2 cd testdata cmd3 After exiting the program, the CWD remains the same as where I execute the program. I need it to be changed to the latest updated directory in the program. How can I do... (1 Reply)
Discussion started by: vadivel
1 Replies
Login or Register to Ask a Question