Questions tagged [getcwd]

The getcwd() function retrieves the current working directory pathname on POSIX compliant machines.

The function getcwd() is available on Unix machines to copy the current working directory (as an absolute pathname) to a supplied buffer of an array of characters of a given length. It is specified in POSIX.1-2001 to have the following signature:

char *getcwd(char *buffer, size_t size);
104 questions
0
votes
1 answer

Isolate state change of chdir within python exec scope

Running a script with exec, how does one "backup" python process global state in its entirety and restores it afterwards? code example: import os print(os.getcwd()) a = 8 print(a) exec_scope = {} exec(""" import os os.chdir('../new place') a =…
AturSams
  • 7,568
  • 18
  • 64
  • 98
0
votes
1 answer

How do you reconcile the path of a file inside mySQL with the domain name your browser puts in front of it, to view it?

I'm successfully uploading some files to a folder and saving the path in table. If I display the file's path in an html table, hovering over it, the address on deck to be linked always has my domain.com/folder infront of the local path (which also…
thirtywest
  • 13
  • 5
0
votes
1 answer

How to #define strings the right way?

I am recreating a basic bash like shell and I use getcwd for determining the path I am currently in to print it in a nice way. I have this in my header file: #define BLUE "\e[1;36m" #define WHITE "\e[0;00m" #define PWD getcwd((NULL), 0) #define…
Blifix
  • 1
0
votes
1 answer

TypeError: Error: unsupported operand type(s) for +: 'builtin_function_or_method' and 'str'

import os directory = os.getcwd if os.path.exists(directory + "\\token.txt"): print('token file aleady exists. terminating token setup') else: tokenfile = open("token.txt", "x") the error is coming from this line: if…
fameless
  • 11
  • 1
0
votes
1 answer

Tcl print cwd and use it as string

I was making a small script in tcl for VMD: mol load psf run_1/structure.psf xtc run_1/postDocking_wrapped.xtc set final [atomselect top "not (water or ions or resid 1216)" frame last] $final writepdb last_frame.pdb puts "finished!" quit I wish i…
0
votes
2 answers

Python - os.getcwd() doesn't return the full path

At the start of the file, I specified the path using: path = r"C:\Documents\Data" os.chdir(path) Later on, I want to iterate through subfolders in the Data folder. This folder contains 2018, which contains Level2A. I do this with: for root,…
Niek
  • 51
  • 8
0
votes
2 answers

'Ignoring return value' warning

I am receiving warning: ignoring return value of 'getcwd', declared with attribute warn_unused_result #define get_current_dirr when running this code: #define get_current_dir getcwd FILE *open_particle_data() { FILE *data_file; char…
steve
  • 1
  • 2
0
votes
2 answers

List processes running in a given directory

I'm dealing with an application, that brings up a multitude of separate processes, some of which sometimes do not go away, when asked politely -- by using the application's own means. Which means, they have to be evicted rudely (with SIGTERM) and…
Mikhail T.
  • 3,043
  • 3
  • 29
  • 46
0
votes
1 answer

Trying to create a code that print absolute path and last modify time of file

WHAT I HAVE TO DO I have to find, starting from a directory, a file located in one of all directories that have as root the directory passed in input. Something as shell command find. INPUT/OUTPUT Having this in input: ./myfind…
ClaudioDeLise
  • 247
  • 1
  • 9
0
votes
1 answer

CodeDeploy getcwd: cannot access parent directories: No such file or directory

We have a repeating problem where CodeDeploy just loses access. This problem is bugging me and out Amazon AWS reseller support team for a few months now. After fresh instance ec2 creation our deploy works fine. After few days 7-14 days (10-30…
0
votes
0 answers

How to save a file in current working directory with pyautogui?

I'm trying to save a webpage through selenium and "ctrl+s" via pyautogui. But I couldn't change the directory for saving when the save file window comes. The examples I could find about it are to save the screenshot in a specified directory.…
mulaixi
  • 183
  • 2
  • 11
0
votes
2 answers

C - is calling getcwd causing a bug here?

I'm learning syscalls like stat and readlink. I try to stat the root directory in two different ways: Just stat the path to root. Simple. Then, a roundabout way, fopen "/", make a file descriptor path from the fd I get and readlink it to get "/".…
Andrew Cina
  • 134
  • 10
0
votes
1 answer

How to get relative path of dir?

I`m implementing pwd builtin in mini shell. How could I get relative path without using environment variable "PWD" (getenv("PWD")) Example: CWD = /tmp getcwd("/tmp", buff, size) returns absolute location => /private/tmp. How can I get "/tmp"…
0
votes
8 answers

Wrap C block in function. Beginner question

I found the C snippet to get the current working directory from here. Essentially, the code is: char directory[_MAX_PATH]; getcwd(directory, sizeof(directory)) I want to abstract that into another function, in a different file (so it can be swapped…
Adam
  • 5,091
  • 5
  • 32
  • 49
0
votes
1 answer

How to Run a Specific Powershell Command Within Python with a Defined Variable and Print Output?

I am trying to run a specific command from Python to Powershell: The command works as expected in Powershell. The command in Powershell is as following: gpt .\Method\gpt_scripts\s1_cal_deb.xml -t…