Questions tagged [chdir]

chdir (or cd) is a command to change the working directory (change directory). It is part of many operating systems and programming languages. On many OS `chdir()` also is a system call.

cd, sometimes also available as chdir (change directory), is a command line command to change the current working directory in operating systems such as Unix, DOS, OS/2, AmigaOS (where if a bare path is given, cd is implied), Windows, and Linux. It is also available for use in shell scripts and batch files.

More details see cd Wikipedia article

202 questions
1
vote
1 answer

chdir(getenv("HOME") prompts error "No such file or directory"

Being quite new to writing shell. I am trying to get "cd" to go to home directory when I don't give any extra argument. But when I call "cd" and the code tries to chdir(getenv("HOME")), it shows an error message "No such file or directory". /* …
donkey
  • 4,285
  • 7
  • 42
  • 68
1
vote
2 answers

How can you execute a command outside of your current working directory in WinCvs?

I'm working on a Perl wrapper to execute commands within WinCvs. I have been unable to find a way to execute Cvs commands without doing a chdir to the directory that you wish to execute the command on. This is very annoying because it means that…
tjwrona1992
  • 8,614
  • 8
  • 35
  • 98
1
vote
2 answers

implementing cd command using chdir() in linux

I am writing my own shell program. I am currently implementing the cd command using chdir. I want to implement the chdir with the below options : -P Do not follow symbolic links -L Follow symbolic links (default) I posted a question here previously…
hits_lucky
  • 327
  • 2
  • 9
  • 18
1
vote
2 answers

Can I change a require()'d module's cwd without using process.chdir()

I have a NodeJS module that does a lot of work on the filesystem in a particular directory. I would like all filesystem operations inside the module to be done relative to that directory - (let's call it /home/me/data). I realise I could change the…
Mike Monteith
  • 521
  • 1
  • 6
  • 18
1
vote
1 answer

python:os.system(r'cd foo') & os.chdir()

I was having a doubt.When I tried os.system(r'cd F:\') I was still in the directory where I started the interpreter.But `os.chdir()' worked fine.I'll show my code below: >>> import os >>> os.system('F:') 0 By running the os.system('dir') I found…
user4696550
1
vote
2 answers

Find out if a directory exists in php

I want to know whether or not a directory exists. If not, I would like to create the directory. My code is below: $da = getdate(); $dat = $da["year"]."-".$da["mon"]."-".$da["mday"]; $m = md5($url)."xml"; if(is_dir($dat)) { chdir($dat); $fh =…
zahir hussain
  • 3,711
  • 10
  • 29
  • 36
1
vote
1 answer

chdir(..) returns 0 for success and changes directory, but outputs "No such file or directory"

I'm implementing cd functionality using system calls in a C program that acts as a simple shell, and am having a bit of an issue with directory names. I have a feeling it's trivially string related, but I haven't had any luck so far. I have a…
lreichold
  • 755
  • 12
  • 27
1
vote
2 answers

Odd issue creating cd-esque structure in python

I've written a program whose main thrust is to continually ask the user for data file names and then to graph those files. However, those files exist in various directories, by design. I decided it'd be nice to be able to navigate around in the…
erekalper
  • 857
  • 9
  • 22
1
vote
1 answer

Python change directory returns strange error

I think it's a basic python problem, but I just can't find out why. I have a file named tc_500 containing some CSV files I want to edit, thus I change the directory in order to edit these files. import sys,…
Heinz
  • 2,415
  • 6
  • 26
  • 34
1
vote
4 answers

How to get python to know what directory you're working in

I have a program that I wrote that goes through all of the files in a directory and looks for files with a flag and then inputs them into a different program. It works great, the only thing that I am trying to do now it put the script in one…
Michael R
  • 259
  • 5
  • 16
1
vote
2 answers

python find file and change directory to file path

I'm wanting to use os.walk to search the cwd and subdirectories to locate a specific file and when found immediately break and change to that dir. I've seen many examples where it breaks after locating the file, but I can't figure out how to…
Gary Washington
  • 107
  • 1
  • 3
  • 9
1
vote
1 answer

chdir in php can't work

I want to change directory using chdir in php, because i need to execute command in Linux. My current directory is /var/www/httpdocs/website/admin,I want to go to httpdocs's sub_directory docs.I use absolute path…
Kara
  • 11
  • 1
  • 2
1
vote
2 answers

How to make chdir() stay in the specified directory after the program finishes?

I have a program that calls chdir() to change the cwd. However, after the program finishes the cwd changes back to the directory that called the program instead of staying the in one specified by the call to chdir(). I made a program to test if…
sardoj
  • 33
  • 1
  • 4
1
vote
2 answers

perl chdir and system commands

I am trying to chdir in perl but I am just not able to get my head around what's going wrong. This code works. chdir('C:\Users\Server\Desktop') But when trying to get the user's input, it doesn't work. I even tried using chomp to remove any spaces…
The Last Word
  • 203
  • 1
  • 7
  • 24
1
vote
3 answers

Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "On systems that support fchdir, you might pass a…
sid_com
  • 24,137
  • 26
  • 96
  • 187