CHDIR(2) System Calls Manual CHDIR(2)NAME
chdir - change current working directory
SYNOPSIS
#include <unistd.h>
int chdir(const char *path)
DESCRIPTION
Path is the pathname of a directory. Chdir causes this directory to become the current working directory, the starting point for path
names not beginning with ``/''.
In order for a directory to become the current directory, a process must have execute (search) access to the directory.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
ERRORS
Chdir will fail and the current working directory will be unchanged if one or more of the following are true:
[ENOTDIR] A component of the path prefix is not a directory.
[ENAMETOOLONG] The path name exceeds PATH_MAX characters.
[ENOENT] The named directory does not exist.
[ELOOP] Too many symbolic links were encountered in translating the pathname. (Minix-vmd)
[EACCES] Search permission is denied for any component of the path name.
[EFAULT] Path points outside the process's allocated address space.
[EIO] An I/O error occurred while reading from or writing to the file system.
SEE ALSO chroot(2).
4th Berkeley Distribution August 26, 1985 CHDIR(2)
Check Out this Related Man Page
CHDIR(2) BSD System Calls Manual CHDIR(2)NAME
chdir, fchdir -- change current working directory
SYNOPSIS
#include <unistd.h>
int
chdir(const char *path);
int
fchdir(int fd);
DESCRIPTION
The path argument points to the pathname of a directory. The chdir() function causes the named directory to become the current working
directory, that is, the starting point for path searches of pathnames not beginning with a slash, '/'.
The fchdir() function causes the directory referenced by fd to become the current working directory, the starting point for path searches of
pathnames not beginning with a slash, '/'.
In order for a directory to become the current directory, a process must have execute (search) access to the directory.
RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
ERRORS
Chdir() will fail and the current working directory will be unchanged if one or more of the following are true:
[ENOTDIR] A component of the path prefix is not a directory.
[ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters.
[ENOENT] The named directory does not exist.
[ELOOP] Too many symbolic links were encountered in translating the pathname.
[EACCES] Search permission is denied for any component of the path name.
[EFAULT] Path points outside the process's allocated address space.
[EIO] An I/O error occurred while reading from or writing to the file system.
Fchdir() will fail and the current working directory will be unchanged if one or more of the following are true:
[EACCES] Search permission is denied for the directory referenced by the file descriptor.
[ENOTDIR] The file descriptor does not reference a directory.
[EBADF] The argument fd is not a valid file descriptor.
SEE ALSO chroot(2)STANDARDS
The chdir() is expected to conform to IEEE Std 1003.1-1988 (``POSIX.1'').
HISTORY
The fchdir() function call appeared in 4.2BSD.
4th Berkeley Distribution December 11, 1993 4th Berkeley Distribution
I need to CD to a particular directory to check log files and interface files. Instead of typing the path manually, is there a way of getting a script to change my working directory to the one I need?
Currently I have a script that CD's to the directories I need but a soon as the script exits,... (5 Replies)
I can't see the name of the directory path when i connect to server with telnet. What can i do? Thanks.
Example:
#cd directory1
#cd directory2
#cd directory3
#_ (current directory is directory3)
but i want this
#cd directory1
#directory1> cd directory2... (8 Replies)
How to change current working directory for dbx on UNIX?
means I'll run pgm from one directory , but getcwd() should return path which I want to be, which is not d current dir
:) (5 Replies)
Hi,
This is certainly a simple question, but I have yet to receive sufficient info concerning it. I am using BASH on a Powerbook G4 running Leopard.
- I would like to permanently add a directory to my path. How do I do this?
- I understand that I can view my path by: echo $PATH. Is there a... (4 Replies)
Hello fellow UNIX fans,
I'm running AIX 4.3 and getting an error message “cp: /a/file2.db: A file or directory in the path does not exist” when I run the following command:
cp /b/file.db /a/file2.db
It stops every time about 95% of the way through the copy process at 1,073,741,312 bits. ... (3 Replies)
Stupid question, but is there an ANSI C stdlib function that will do this for me? I want to pass the function a path and determine if the current process can read/write/execute on the path. I suppose I can whip something up using fstat and then determining the current process's user/group IDs and... (6 Replies)
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)
Hello Guys,
I am working on a script and using the below code to fetch the list of all repositories
CHDIR='/mnt/scm/subversion/'
repolist()
{
cd ${CHDIR}
Repo=`ls|cut -d " " -f1`
echo $Repo
}
Output of the above code is
BSB CIB COB DCI DIB DSB ESB-P ESB-TOOLS FareVerify GCACHE GWY... (15 Replies)
Hi,
I've some directory that I used as working directory for a program. At the end of the procedure, the content is deleted. This directory, when I do a ls -l, appears to still take up some space. After a little research, I've seen on a another board of this forum that it's not really taking... (5 Replies)
I want to traverse a durectory for a particular file. Situataion is like this. Path is ABC/a/c/g. it has around 100 folders in it.
Search a directory which has word "*latest*" in its path.
and then from the latest go through z/x/c to file final.html.
In total, i want it to go through... (4 Replies)
Hi guys,
In Windows, whenever I want a execute a program using just a relative path on the command prompt, I simply edit the 'Path' variable and append my parent directory.
Is there something like this available in Unix? I have a binary for Virtualbox called VBoxManage that I want to execute... (6 Replies)
Hello everyone,
I need some help renaming files. I have a directory with a bunch of subfolders in it like so with DWI being the working directory and the 3 levels after it being subdirectories
home/user/Documents/DWI/111180-100/3t_2016-01-07_21-42/003_DTI_siemens_TClessdistort/dtifit_FA.nii.gz... (8 Replies)
I'm brand new to AIX and I looked up how to print this file and it was working but now I'm not able to do it all of a sudden. the file name is rom1.txt so this is what i wrote in the command line and I know I'm in the right directory. In bold is what I seem to be messing up with.
prod @ root... (3 Replies)