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
6
votes
1 answer

chdir() - no such file or directory

int main(int argc, char **argv) { char input[150]; char change[2] = "cd"; char *directory; while(1) { prompt(); fgets(input, 150, stdin); if(strncmp(change, input, 2) == 0) { directory = strtok(input, " "); …
csczigiol
  • 73
  • 1
  • 5
5
votes
2 answers

Changing working directory in C?

Im new to C and am having trouble using chdir(). I use a function to get user input then I create a folder from this and attempt to chdir() into that folder and create two more files. Howver when I try to access the folder via finder (manually) I…
Dragan Marjanovic
  • 1,287
  • 5
  • 16
  • 27
4
votes
1 answer

Can chdir() accept relative paths?

In C on linux, can the chdir() function accept a relative path?
John Moffitt
  • 5,730
  • 7
  • 30
  • 39
4
votes
2 answers

How does fchdir work?

In it's main page it says: fchdir() is identical to chdir(); the only difference is that the directory is given as an open file descriptor. And the prototype is given as following: int chdir(const char *path); int fchdir(int fd); My question…
UtkarshPramodGupta
  • 7,486
  • 7
  • 30
  • 54
4
votes
3 answers

Perl directory change from Windows cmd.exe

According to the manual, chdir, Changes the working directory to EXPR, if possible. This script, when executed from cmd.exe: my $path = 'C:\\some\\path\\'; print "$path\n"; chdir("$path") or die "fail $!"; results in this output: C:\some\path\ but…
dls
  • 4,146
  • 2
  • 24
  • 26
4
votes
4 answers

chdir() & multithreading in C

Is it possible to use chdir() or some other command to change the directory in a thread without affecting the cwd of the other threads ? I'm using pthread.h. *I'm trying to write a server program that handles multiple client connections and…
IrishDog
  • 460
  • 1
  • 4
  • 21
4
votes
1 answer

chdir not declared, compilation error g++

I am trying to compile a relatively simple application that I obtained from the web.. When running make I get the following error: In file included from main.cpp:2:0: os.h: In function ‘void myOpenDir(const char*)’: os.h:13:16: error: ‘chdir’ was…
Jasper
  • 628
  • 1
  • 9
  • 19
3
votes
1 answer

Using Python, how to download multiple files from a subdirectory on FTP server into a desired directory on local machine?

Using python program, I was able to download multiple source files from a FTP server (using ftplib and os libraries) to my local machine. These source file resides at a particular directory inside the FTP server. I was able to download the source…
Mech_Saran
  • 157
  • 1
  • 2
  • 9
3
votes
1 answer

How can I change directories in a thread safe way?

I'd like to spawn 2 threads and move each one into a different working directory. std::thread t1([](){ boost::filesystem::current_path("/place/one"); // operate within "place/one" }); std::thread t2([](){ …
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
3
votes
0 answers

What can cause the working directory to be changed (if `Dir.chdir` is not called)?

I have a script that uses Dir.getwd to get the current working directory multiple times. Then it does things with it. This works for 99.9% of the users all of the time but for some users it returns an unexpected value in some cases. This causes an…
janpio
  • 10,645
  • 16
  • 64
  • 107
3
votes
1 answer

Change directory in REXX exec running in z/OS USS?

I'm in the USS shell under TSO, and I have this exec (named tryit): /* rexx */ "cd /differentdir" "pwd" Here's the result: > pwd /origdir > tryit /origdir In other words, the effects of the cd command appear to last only for the duration of the…
Oh Come On
  • 153
  • 8
3
votes
4 answers

chdir programmatically

In Windows -- and probably Unix for that matter -- using the chdir() function in a (32-bit) program doesn't change the directory when the program exits. (It does in a 16-bit Windows program.) Does anybody know how to do that in a Windows 32-bit…
james owen
3
votes
2 answers

Batch script fails with "The system cannot find the path specified"

I have written the following batch script, which runs another batch script on a directory, or, with addition of a flag, on a directory tree and then on an equivalent directory or directory tree on a different drive (Z:). No matter which option I…
ZackG
  • 177
  • 3
  • 3
  • 9
3
votes
3 answers

If I chdir within a thread, will that affect the cwd of the parent program?

If I chdir within a thread, will that affect the cwd of the parent program?
porque_no_les_deux
  • 479
  • 1
  • 6
  • 18
3
votes
2 answers

inspect.getmodule's result change after os.chdir

Some code of mine sprung a bug seemingly out of nowhere. When I tracked it down, I found that evaluating inspect.getmodule with the same (identical) argument before and after executing os.chdir gives different results. (FWIW, I'm running Python…
kjo
  • 33,683
  • 52
  • 148
  • 265
1
2
3
13 14