11-10-2008
chroot is not what you want, it changes the / path to be the named dir, so any subsequent calls will have that as their / path - not a good idea
chdir() is what you need
man 2 chdir will give you information on chdir (on a linux machine anyway)
10 More Discussions You Might Find Interesting
1. Programming
Hi I want to implement the nice command in the shell that I am building. I came to know that there is a corresponding nice() system call for the same. But since I will be forking different processes to run different commands typed on the command prompt, is there any way I can make a command... (2 Replies)
Discussion started by: tejbuch
2 Replies
2. UNIX for Advanced & Expert Users
Hi,
Ho do I differentiate system call from library call?
for example if I am using chmod , how do I find out if it is a system call or library call?
Thanks
Muru (2 Replies)
Discussion started by: muru
2 Replies
3. Shell Programming and Scripting
HI,
if I have a tarfile called pmapdata.tar that contains
tar -tvf pmapdata.tar
-rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt
-rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt
-rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies
4. Shell Programming and Scripting
Hi every one,
i have to dot pc files. One have main function but one dont have.I have to call dot pc file using system () cmd.File is being call have main function.Please let me know how i can call .pc file with two arguments from other dot pc file.I want some thing like
sprintf(buf,... (1 Reply)
Discussion started by: goraya430
1 Replies
5. Programming
Hi every one,
i have to dot pc files. One have main function but one dont have.I have to call dot pc file using system () cmd.File is being call have main function.Please let me know how i can call .pc file with two arguments from other dot pc file.I want some thing like sprintf(buf, "ss_xxx.pc... (4 Replies)
Discussion started by: goraya430
4 Replies
6. Shell Programming and Scripting
Hi All,
I have a script(sample.sh) displaying the output of "dd" command. Now i am using this script in system() call as,
system("sh sample.sh") in an application file.
I want the output of system("sh sample.sh") in the application file itself.
How can i get it?
Many thnaks.... (9 Replies)
Discussion started by: amio
9 Replies
7. Shell Programming and Scripting
Hello experts,
I have a perl script which looks for the ARGV and then loads the data as per it.
Example.
#Checking the server to connect
if ($ARGV eq 'QA')
{
$ENV{"ORACLE_HOME"} = "/oracle/product/11.2.0";
$ENV{"PATH"} = "$ENV{'PATH'}:/oracle/product/11.2.0/bin";
... (1 Reply)
Discussion started by: msrahman
1 Replies
8. Programming
hi everyone
i wrote a system call and compiled the kernel succesfully...
my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c)
the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h
my problem is... (2 Replies)
Discussion started by: demis87
2 Replies
9. Shell Programming and Scripting
Hello,
Recently, I've started with shell scripting, and decided to write a script for my system backup using tar. When I was dealing with tar execution inside shell script I found this, inside shell we have the following code:
tar $TAR_PARAMS $ARCHIVE_FILE $EXCLUDE $BACKUP_STARTwith... (6 Replies)
Discussion started by: ilnar
6 Replies
10. Shell Programming and Scripting
Hi all,
I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies
chdir(2) System Calls chdir(2)
NAME
chdir, fchdir - change working directory
SYNOPSIS
#include <unistd.h>
int chdir(const char *path);
int fchdir(int fildes);
DESCRIPTION
The chdir() and fchdir() functions cause a directory pointed to by path or fildes to become the current working directory. The starting
point for path searches for path names not beginning with / (slash). The path argument points to the path name of a directory. The fildes
argument is an open file descriptor of a directory.
For a directory to become the current directory, a process must have execute (search) access to the directory.
RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned, the current working directory is unchanged, and errno is set to indi-
cate the error.
ERRORS
The chdir() function will fail if:
EACCES Search permission is denied for any component of the path name.
EFAULT The path argument points to an illegal address.
EINTR A signal was caught during the execution of the chdir() function.
EIO An I/O error occurred while reading from or writing to the file system.
ELOOP Too many symbolic links were encountered in translating path.
ENAMETOOLONG The length of the path argument exceeds PATH_MAX, or the length of a path component exceeds NAME_MAX while
_POSIX_NO_TRUNC is in effect.
ENOENT Either a component of the path prefix or the directory named by path does not exist or is a null pathname.
ENOLINK The path argument points to a remote machine and the link to that machine is no longer active.
ENOTDIR A component of the path name is not a directory.
The fchdir() function will fail if:
EACCES Search permission is denied for fildes.
EBADF The fildes argument is not an open file descriptor.
EINTR A signal was caught during the execution of the fchdir() function.
EIO An I/O error occurred while reading from or writing to the file system.
ENOLINK The fildes argument points to a remote machine and the link to that machine is no longer active.
ENOTDIR The open file descriptor fildes does not refer to a directory.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |Async-Signal-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
chroot(2), attributes(5), standards(5)
SunOS 5.10 28 Dec 1996 chdir(2)