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
2
votes
2 answers

How to change Current Working directory using AppleScript

What would be a simplest way to change a current working directory (cwd) using AppleScript. It would be equivalent to OS's cd or Python's os.chdir. Would be great if a destination directory if doesn't exist would be created on a fly (but that would…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
2
votes
3 answers

What's that best way to move through directories?

Are both of the examples below OK, or is the second one bad style? Case 1: Stay in top directory and use catdir to access subdirectories #!/usr/bin/env perl use warnings; use strict; my $dir = 'my_dir_with_subdir'; my ( $count, $dh ); use…
sid_com
  • 24,137
  • 26
  • 96
  • 187
2
votes
1 answer

PHP FTP return to FTP-user Root folder

How can I return to the ftp users root folder. In this example it is /isi/ in my home/user/ dir. $location = $order; $real_location = $workflow_location =$leverancier; if (!@ftp_chdir($ftp_conn, $real_location)) { …
Dyam
  • 33
  • 5
2
votes
2 answers

os.chdir between multiple python processes

I have a complex python pipeline (which code I cant change), calling multiple other scripts and other executables. The point is it takes ages to run over 8000 directories, doing some scientific analyses. So, I wrote a simple wrapper, (might not be…
Sander
  • 591
  • 6
  • 16
2
votes
1 answer

Ruby: How to get the correct full path of a source file after a chdir?

See the following example: puts __FILE__ #test.rb puts File.expand_path(__FILE__) #C:/TEMP/test.rb Dir.chdir('..') puts __FILE__ #test.rb puts File.expand_path(__FILE__) …
knut
  • 27,320
  • 6
  • 84
  • 112
2
votes
1 answer

Directory traversal with chdir() instead of with absolute paths

In Chapter 4 of the book "Advanced Programming in the Unix Environment," which covers files and directories, there is a code sample which aims to be like the ftw command and traverse a file hierarchy. It uses a pointer to an absolute file path, as…
rsa
  • 585
  • 4
  • 16
2
votes
2 answers

Change directory of parent process after exit

Possible Duplicate: How do I set the working directory of the parent process? Is possible to make the change of directory persist after program exit? Since it resets to original directory when program exits.
user1243746
2
votes
1 answer

Setting current directory for Interactive Console in pydev (Eclipse) at console startup

I want to start an interactive console in pydev from project directory, in order to import an app. I tried to use os.chdir at startup from Window->Preferences->PyDev->Interactive Console->Initial interpreter commands. I read…
gc5
  • 9,468
  • 24
  • 90
  • 151
1
vote
1 answer

Can I call chdir or setenv after fork on Mac OS X?

On OS X, the man page for fork says this: There are limits to what you can do in the child process. To be totally safe you should restrict yourself to only executing async-signal safe operations until such time as one of the exec functions is…
George
  • 4,189
  • 2
  • 24
  • 23
1
vote
2 answers

php popen and php current working directory

If I use PHP's popen command to execute a script, does is execute it in the context of PHP's current directory? Currently I am doing something along the lines of popen(' cd PATH; CMD'); but can I do it as chdir ('PATH'); popen('CMD');
Eric Pigeon
  • 1,091
  • 2
  • 10
  • 21
1
vote
2 answers

Python: os.chdir() not working within a for loop?

I'm trying to get a homemade path navigation function working - basically I need to go through one folder, and explore every folder within it, running a function within each folder. I reach a problem when I try to change directories within a for…
morgoe
  • 350
  • 4
  • 16
1
vote
1 answer

Using chdir with an absolute path

I am trying to use chdir inside a function which writes & saves a file. If I try to write the file to a nearby folder e.g. 'bins' like so: $location = 'bins'; chdir($location); then it works fine and the files are written and placed into the bins…
Daniel Hutton
  • 1,455
  • 1
  • 17
  • 33
1
vote
3 answers

Perl chdir error

I am trying to change the working directory (for configure a WebShpere MQ Queue manager) using Perl in UNIX. I have to go to the directory /var/mqm/qmgrs/Q\!MAN and I have used following code snippet: $QueueManagerPathName =…
DarRay
  • 2,550
  • 6
  • 27
  • 39
1
vote
1 answer

Sanitizing command parameters in a DOSKEY macro

Let's say I have the following in my AutoRun script: @doskey cd = @( ^ for /f usebackq^^ delims^^=^^ eol^^= %%a in (^ '$* ' ^ ) do @( ^ if "%%~a"==" " ( ^ if /i not "%%CD%%"=="%%USERPROFILE%%" ( ^ …
mataha
  • 155
  • 7
1
vote
1 answer

Implementation of the command cd (cd -L) in C without exec functions

I'm trying to code the command cd in C without using the exec functions, I already did the cd -P version but I can't seem to find a way to do cd (cd -L) because the function chdir resolves the symlinks so my cd -L acts like cd -P. For cd -P I did…
Chae
  • 13
  • 3