Problem with /usr/bin/cd command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with /usr/bin/cd command
# 1  
Old 03-03-2009
Java Problem with /usr/bin/cd command

Hi ,

My shell script doesnt function properly while executing.

My shell script has the below mentioned code in it.
#!/bin/sh
CD="/usr/bin/cd"
..
..
$CD /
..
..

main intention behind giving the $CD / is to replace the cd command with /usr/bin/cd at the time of program execution.

but this is not working..

I tried by setting PATH to /usr/bin and /usr/sbin but both didnt work..

Could any one please give me a soultion how to make /usr/bin/cd (not just cd ..cd is working fine)working in the code.

Thanks in advance
RaghuDeep Amilineni
raghu.amilineni
# 2  
Old 03-03-2009
small mistake
CD="cd /usr/bin/cd"
now it should run
# 3  
Old 03-03-2009
Quote:
Originally Posted by raghu.amilineni
Hi ,

My shell script doesnt function properly while executing.

My shell script has the below mentioned code in it.
#!/bin/sh
CD="/usr/bin/cd"
..
..
$CD /
..
..

main intention behind giving the $CD / is to replace the cd command with /usr/bin/cd at the time of program execution.

but this is not working..

I tried by setting PATH to /usr/bin and /usr/sbin but both didnt work..

Could any one please give me a soultion how to make /usr/bin/cd (not just cd ..cd is working fine)working in the code.

Thanks in advance
RaghuDeep Amilineni
cd is a built in command not an external command:

Code:
cd /

is sufficient, instead of:

Code:
CD="/usr/bin/cd"
$CD /


Regards
# 4  
Old 03-03-2009
It sounds like maybe you want the "alias" command. Check the man page.

Are you trying to make it so that if the user types "cd" during the session, a different command of your choosing is executed instead of the default "cd" command?
# 5  
Old 03-03-2009
If you read "man cd" you'll see "cd is a built-in command".
Whenever you will try to use /usr/bin/cd or /bin/cd directly, there is no result.

--> Why do you want to replace "cd" by "/usr/bin/cd" ???
# 6  
Old 03-03-2009
Quote:
Originally Posted by raghu.amilineni
Could any one please give me a soultion how to make /usr/bin/cd (not just cd ..cd is working fine)working in the code.

cd cannot work as an external command. An external command creates a child process, and a process cannot affect the environment of its parent.

It exists as an external command in order to simplify some wording in the POSIX standard (see <http://www.opengroup.org> for more information).
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. BSD

FreeBSD: /usr/bin/ld not looking in /usr/local/lib

I'm not sure if this is the default behavior for the ld command, but it does not seem to be looking in /usr/local/lib for shared libraries. I was trying to compile the latest version of Kanatest from svn. The autorgen.sh script seems to exit without too much trouble: $ ./autogen.sh checking... (2 Replies)
Discussion started by: AntumDeluge
2 Replies

2. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

3. Solaris

Execution problem with "/usr/dt/bin/sdtdbcache

On a SunOS Solaris 5.5.1 workstation, the /usr/dt/bin/sdtdbcache –init command lasts more than 20 minutes. This command is executed by the /usr/dt/bin/Xsession script during an user connection. Please refrain from using subjects like "HELP ME!..." to get more/faster attention and also please do... (1 Reply)
Discussion started by: ricadom
1 Replies

4. Solaris

How do I link ld in /usr/ucb/ to /usr/ccs/bin?

Hi all, below is the problem details: ora10g@CNORACLE1>which ld /usr/ucb/ld ora10g@CNORACLE1>cd /usr/ccs/bin ora10g@CNORACLE1>ln -s /usr/ucb/ld ld ln: cannot create ld: File exists ora10g@CNORACLE1> how to link it to /usr/ccs/bin? (6 Replies)
Discussion started by: SmartAntz
6 Replies

5. Solaris

Which package i need to install for corresponding command: /usr/bin/7za?

Hi friends, I need install a CAM on a lack package cluster Solaris 10 OS Sparc. I read the prequirements, OS is missing 2 pkgs: SUNWtcatu SUNWxwrtl I try add by a OS 10-08 CD, To install SUNWtcatu it also missing SUNWj3rt SUNWj3dev To install SUNWj3rt, it show: Cannot find required... (5 Replies)
Discussion started by: tien86
5 Replies

6. UNIX for Dummies Questions & Answers

problem in /var/log/messages and /usr/bin/last

Unfortunately., i had remove the files /var/log/messages and /usr/bin/last in our server, we have to touch another one and change the permissions also but not working still now. help me yours thakshina (2 Replies)
Discussion started by: thakshina
2 Replies

7. Linux

Problem with /usr/bin

I installed an application in this location /root/jython and I added a link to the /usr/bin because i want everyone on the system to be able to execute this ln -s /root/jython/jython jython I can execute this anywhere when i am logged in as root but when i change user to say juju it returns ... (1 Reply)
Discussion started by: oyesiji
1 Replies

8. Shell Programming and Scripting

#!/usr/bin/ksh Command Interpreter in a sh script

Hi, I have a developer that is trying to start a script with sh "scriptname". In the script, he is specifying #!/usr/bin/ksh as the command interpreter. For some reason sh is ignoring the #!/usr/bin/ksh. We are running Solaris 8. Does anyone have any ideas what could be causing this? Here... (3 Replies)
Discussion started by: ckeith79
3 Replies

9. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies
Login or Register to Ask a Question