absolute-path

Python won't exit when called with absolute path from cron or subshell

我的梦境 提交于 2019-11-29 12:08:55
I have some python scripts that run via cron, and they no longer exit correctly when the script is called with an absolute path. They will hang until the process is terminated. I believe it happened after I moved /var and /home to a different partition. I checked into the environment variables and couldn't see anything obviously wrong, this happens either when run with cron or a bash subshell, but not when run directly. If I run it as a subshell it hangs until I kill it (ctrl-c) and then gives me the output. [wotstats@rock test]$ echo 'assert 0==1, "fails"' > test.py [wotstats@rock test]$ /bin

Get relative path of the page url using javascript

喜夏-厌秋 提交于 2019-11-29 10:57:54
问题 In javascript, how can I get the relative path of the current url? for example http://www.example.com/test/this?page=2 I want just the /test/this?page=2 回答1: Try window.location.pathname+window.location.search 回答2: location.href holds the url of the page your script is running in. 回答3: The quickest, most complete way: location.href.replace(/(.+\w\/)(.+)/,"/$2"); 回答4: You can use the below snippet to get the absolute url of any page. var getAbsoluteUrl = (function() { var a; return function

When to use Absolute Path vs Relative Path in Python

吃可爱长大的小学妹 提交于 2019-11-29 10:50:54
For reference. The absolute path is the full path to some place on your computer. The relative path is the path to some file with respect to your current working directory (PWD). For example: Absolute path: C:/users/admin/docs/stuff.txt If my PWD is C:/users/admin/ , then the relative path to stuff.txt would be: docs/stuff.txt Note, PWD + relative path = absolute path. Cool, awesome. Now, I wrote some scripts which check if a file exists. os.chdir("C:/users/admin/docs") os.path.exists("stuff.txt") This returns TRUE if stuff.txt exists and it works . Now, instead if I write, os.path.exists("C:

How to find relative path given two absolute paths?

吃可爱长大的小学妹 提交于 2019-11-29 10:45:21
Given two absolute paths, e.g. /a/path/to/a /a/path/to/somewhere/else How can I get a relative path from one to the other, ../a ? In a sense, the opposite of what realpath does. Thomas Dickey I answered a similar question here: Resolving a relative path without referencing the current directory on Windows . There is no standard function for this. There is a function in vi-like-emacs for this purpose. A quick check of apropos relative shows me few other programs which likely implement this: revpath for example). It could be done as a string-manipulation (no need to compute working directories):

How to get absolute path of file or directory, that does *not* exist?

别来无恙 提交于 2019-11-29 09:18:41
How can I determine the absolute path of a file or directory from a given relative path in C/C++ on GNU/Linux? I know about realpath() , but it does not work on non-existing files. Let's say the user enters ../non-existant-directory/file.txt , and the programs working directory is /home/user/ . What I need is a function that returns /home/non-existant-directory/file.txt . I need this function to check if a given path is in a certain subdirectory or not. Try realpath . If it fails, start removing path components from the end one at a time and retrying realpath until it succeeds. Then append the

Relative path or absolute path and how to set up in PHP

走远了吗. 提交于 2019-11-29 08:34:49
I have a site that I am working on and I am trying to go to the main directory of the site and I do not know how to set that up. What I am trying to do is include _inc/config.php through /_inc/config.php instead of having to use ../_inc/config.php Any ideas how to add this? Generally speaking, there are two different problems to solve when dealing with paths: Filesystem paths (which you need to use to include a file) URL paths (which you need to use when building a URL internal to your application) These are two different beasts. Filesystem paths If your application has a single point of entry

How to determine the directory in which a running Haskell script or application lives?

烈酒焚心 提交于 2019-11-29 06:27:40
I have a Haskell script that runs via a shebang line making use of the runhaskell utility. E.g... #! /usr/bin/env runhaskell module Main where main = do { ... } Now, I'd like to be able to determine the directory in which that script resides from within the script, itself . So, if the script lives in /home/me/my-haskell-app/script.hs , I should be able to run it from anywhere, using a relative or absolute path, and it should know it's located in the /home/me/my-haskell-app/ directory. I thought the functionality available in the System.Environment module might be able to help, but it fell a

Server Document Root Path in PHP [closed]

怎甘沉沦 提交于 2019-11-29 05:36:10
I have a php code line like below $files = glob('myFolder/*'); I want to use absolute path to myFolder in above by using server document root, like below $_SERVER["DOCUMENT_ROOT"]."/myFolder/" It should be like below $files = glob('$_SERVER["DOCUMENT_ROOT"]."/myFolder/*"'); But this is not working How to correct this? Actually I am trying to do this: <?php //Delete All files from folder // $files = glob('myFolder/*'); $files = glob($_SERVER["DOCUMENT_ROOT"]."/myFolder/*"); foreach($files as $file){ if(is_file($file)) unlink($file); } ?> Code below is working $files = glob('myFolder/*'); This

how to find the target file's full(absolute path) of the symbolic link or soft link in python

醉酒当歌 提交于 2019-11-28 21:00:27
when i give ls -l /etc/fonts/conf.d/70-yes-bitmaps.conf lrwxrwxrwx <snip> /etc/fonts/conf.d/70-yes-bitmaps.conf -> ../conf.avail/70-yes-bitmaps.conf so for a symbolic link or soft link, how to find the target file's full(absolute path) in python, If i use os.readlink('/etc/fonts/conf.d/70-yes-bitmaps.conf') it outputs ../conf.avail/70-yes-bitmaps.conf but i need the absolute path not the relative path, so my desired output must be, /etc/fonts/conf.avail/70-yes-bitmaps.conf how to replace the .. with the actual full path of the parent directory of the symbolic link or soft link file. os.path

How can I get MSBUILD to evaluate and print the full path when given a relative path?

半城伤御伤魂 提交于 2019-11-28 18:31:53
How can I get MSBuild to evaluate and print in a <Message /> task an absolute path given a relative path? Property Group <Source_Dir>..\..\..\Public\Server\</Source_Dir> <Program_Dir>c:\Program Files (x86)\Program\</Program_Dir> Task <Message Importance="low" Text="Copying '$(Source_Dir.FullPath)' to '$(Program_Dir)'" /> Output Copying '' to 'c:\Program Files (x86)\Program\' Roman Starkov In MSBuild 4.0 , the easiest way is the following: $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\your\path')) This method works even if the script is <Import> ed into another script; the path