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);
88 questions
1
vote
2 answers

cwd and gwtcwd returns a linux style path on windows

If I run this script: use Cwd; print "$^O\n"; print cwd; The output is: C:\tmp>perl tmp.pl msys /c/tmp How can I get windows style path C:\tmp?
Pawel P.
  • 2,793
  • 3
  • 18
  • 19
1
vote
3 answers

getcwd() returns NULL after new pointer is created

I've just started learning linux and C, please don't judge me strictly. I'm trying to find a current working directory and to open file in this directory to find a specific word. It gives correct cwd if I find only cwd, but when I added while loop…
Nazerke
  • 1,989
  • 7
  • 32
  • 53
0
votes
3 answers

Do I need to use substr() to bring up a directory or can I another code?

Everything in this file is set up in a way in which $_GET['q'] brings up the main domain name and the other directories in the website are brought up in this manner: else if (substr($_GET['q'], 0, 7) == 'quotes/') If I wanted to have a folder…
Vbena
  • 1
  • 1
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.
  • 2,375
  • 1
  • 20
  • 39
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…
0
votes
0 answers

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

Absolute path or cwd in C for cross-platform

I am working on a mini image processing library which performs basic tasks like edge detection, filtering, hough transforms etc in C. I have a couple of questions: I am using XCode 11 I tried to read an image from the same directory using just the…
0
votes
3 answers

Is there any alternative API for getcwd to get the working direcory of process

In our application we call getcwd(3) to get the current working directory. When the process starts running, if anyone deletes the directory path, then the process is running but getcwd API fails (returns NULL). Example: Process name is: a.exe …
Syedsma
  • 1,005
  • 5
  • 17
  • 22
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
  • 197
  • 2
  • 10
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 "/".…
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
  • 4,733
  • 4
  • 28
  • 48
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…
0
votes
1 answer

os.getcwd() returns a slash (/)

I have a python 3.6 script that I wrote in Atom editor on macOS. The script uses os.getcwd() routinely and has always worked fine. I restarted my computer last night, updated the Atom packages, and suddenly it broke. Using a print statement,…
Kieran Paddock
  • 367
  • 1
  • 5
  • 13
0
votes
0 answers

How does the OS module in python access system functions in linux?

newbie to python and linux here. I dont understand how the OS module in python can access system specific functions for example the getcwd() method which returns the current directory of the system, in linux this would be equivalent of typing in…