w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to get current working directory path of a Qt application?
your application cannot know where the project is, because this is a qt-creator option. if you want to run your binary in the project path you have to setup your working directory inside qt-creator to the right path. then the QDir::currentPath() will return the path you want to have. goto: projects->[environment]->run-> working directory

Categories : C++

Xtend how to get full path of current working directory
Yes, Java has a File class. You can create one by calling this constructor which takes a String. Then you can call getAbsolutePath() on it. You can call it like this: package com.sandbox; import java.io.File; public class Sandbox { public static void main(String[] args) { File file = new File("relative path"); String absolutePathString = file.getAbsolutePath(); } }

Categories : Java

SVN: checkout from multiple URLs to the current working directory under same path?
You can get needed result, while and if COMMON and HOST files are stored in the same repository You use SVN 1.6 or later (I'll recommend to start using 1.8) Solution is file-based externals: re-read carefully "Externals Definitions" in SVN-Book, starting from words Subversion 1.6 also introduced support for external definitions for files. File externals are configured just like externals for directories and appear as a versioned file in the working copy. I.e you files in common/nagios/etc + common/nagios/objects will be maintained files, files inside HOST-tree - externals to files in COMMON (if all files have unique names). Checkouted HOST-tree will have all files in Working Copy (if externals wasn't disabled on checkout)

Categories : Svn

Python joining current directory and parent directory with os.path.join
You can use normpath, realpath or abspath: import os goal_dir = os.path.join(os.getcwd(), "../../my_dir") print goal_dir # prints C:/here/I/am/../../my_dir print os.path.normpath(goal_dir) # prints C:/here/my_dir print os.path.realpath(goal_dir) # prints C:/here/my_dir print os.path.abspath(goal_dir) # prints C:/here/my_dir

Categories : Python

Getting just the current directory without the full path in python
Like this: os.path.split(os.getcwd())[1] Although os.path.split returns a tuple, you don't need to unpack it. You can simply select the item that you need and ignore the one that you don't need.

Categories : Python

Textmate 2 Ruby Run settings for current directory
First of all, this has nothing to do with Textmate but with how Ruby handles that file path. So no need to fiddle with TM settings. You are opening a file relative to the current working directory. If you run Test1.rb from the RubyDevs directory Test2.rb is not present in the current working directory, if you open the file from the RubyLearn directory it is. To make it work from any directory you need to determine the directory of the Test1.rb file and add the Test2.rb path like this: file = File.open(File.dirname(__FILE__) + '/Test2.rb') file.close() Hope this helps!

Categories : Ruby

how can I add current directory to ruby loadpath permanently
$:.unshift File.dirname(__FILE__) Should add the directory of the file you place the snippet on. If you want the directory where you are currently working on (where you call the file from) you can do the following: $:.unshift Dir.getwd

Categories : Ruby

How to change the current working directory to a specific directory and execute a program under the specific directory?
One of your principal problems is that you don't capture the return value (output) of the command in backticks. You are merely throwing away the output you want. Do something like: my $output = `perl ./script.pl` system("perl ./script.pl")

Categories : Perl

How to find a file path in current java directory
Try: String path = System.getProperty("user.dir"); path = path.replaceAll("\","/") + "/etc/xsd/template.xsd" Source: String.replaceAll with Backslashes error

Categories : Misc

Changing directory for User in Ruby script
You can't, but you can do something which might be good enough. You can invoke another shell from ruby: Dir.chdir("/xyz") system("bash") Running this will create a new bash process, which will start in the /xyz directory. The downside is that changing this process will bring you back to the ruby script, and assuming it ends right away - back to the bash process that started the ruby script.

Categories : Ruby

how to get path to ruby.exe that is running current script on windows?
You may take a look at rubinius configure(build_ruby) So, currently it looks as follows: require 'rbconfig' def build_ruby unless @build_ruby bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"] bin += (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '') @build_ruby = File.join(RbConfig::CONFIG['bindir'], bin) end @build_ruby end I also tried the following: require 'rbconfig' File.join( RbConfig::CONFIG['bindir'], RbConfig::CONFIG['RUBY_INSTALL_NAME'] + RbConfig::CONFIG['EXEEXT'] ) It works for me just as good.

Categories : Ruby

python unipath: path to current file directory (ancestor) outputs nothing
Use os.path.abspath(__file__) instead of __file__. This is because __file__ contains a relative path in your case. __file__ can contain a relative path or an absolute one in different situations: So, if you aren't inside the part of sys.path that contains the module, you'll get an absolute path. If you are inside the part of sys.path that contains the module, you'll get a relative path. If you load a module in the current directory, and the current directory isn't in sys.path, you'll get an absolute path. If you load a module in the current directory, and the current directory is in sys.path, you'll get a relative path. (quote from Python __file__ attribute absolute or relative?)

Categories : Python

Batch File: Error in relative path , one level up from the current directory
Your attempt to use %~1 to go up one level in the directory structure is inventive and totally invalid syntax. The proper syntax is just as simple - use ... A leading is not required because %~dp0 ends with a . %windir%Microsoft.NETFrameworkv4.0.30319InstallUtil.exe %~dp0..inERecruitGenerateReportsWindowsService.exe

Categories : Windows

Batch - get current directory before the 'UNC error' modifies cd variable
setting the directory of the batchfile is normally accomplished by set "dirofbatch=%~dp0" (which will include the terminal-) APPDATA is one of windows' reserved names - established by the system for each BATCH session. It may be that its value is assumed by some process, and you've set to to somewhere unexpected. I'd suggest you change that variablename to something else. Similarly, choice is a batch keyword - I'd suggest you make another er, choice, of name. This probably won't actually affect the batch, just a matter of avoiding pitfalls.

Categories : Windows

How to get the current working directory using python 3?
It seems that IDLE changes its current working dir to location of the script that is executed, while when running the script using cmd doesn't do that and it leaves CWD as it is. To change current working dir to the one containing your script you can use: import os os.chdir(os.path.dirname(__file__)) print(os.getcwd()) The file variable is available only if you execute script from file, and it contains path to the file. More on it here: Python __file__ attribute absolute or relative?

Categories : Python

Why pipe resets current working directory?
The pipe does not reset the current working directory. The pipe creates subshells, in bash one for each side of the pipe. The subshell also does not reset the current working directory. The subshell contains the changes to the environment in itself and does not propagate them to the parent shell. In your first script: $ { mkdir dir; cd dir; pwd; } | cat; pwd; The cd is executed inside the left subshell of the pipe. The working directory is changed only in that subshell. The working directory of the parent shell is not changed. The first pwd is executed in the same subshell as the cd so it reads the changed working directory. The pwd at the end is executed in the parent shell so it reads the working directory of the parent shell which was not changed. In your second script: $ { mkdir

Categories : Bash

How to run a process from memory/RAM as the "current working directory"
It sounds difficult, and it will definitely require a lot of stuff that cannot be done in pure Java. On Linux, I think you would need to do the following: Create and mount a "tmpfs" - http://unix.stackexchange.com/questions/66329/creating-a-ram-disk-on-linux Unzip the ZIP file into the tmpfs Run the .exe using ProcessBuilder ... which allows you to set the child processes current directory. etcetera Unmount the "tmpfs" when you've done. The commands for creating the "ram disk" file system will be OS specific, and may require root / administrator privilege. It is unclear whether doing this will be more efficient than using a temporary directory in the file system. I wouldn't attempt this unless there was a clearly demonstrated need for a solution that it more efficient; i.e. unle

Categories : Java

How to change the current working directory in Groovy
As Groovy runs on JVM, the same restrictions apply. Unfortunately it is not possible. Changing the current working directory in Java? JDK bug

Categories : Groovy

Trimming PS1's working directory path
You can create a function and place it in your rc file (perhaps ~/.bashrc) like this: function simplify_dir { local PREFIX if [[ $PWD == "$HOME"* ]]; then PREFIX=${HOME%/} PREFIX=${PREFIX%/*} echo "${PWD##"$PREFIX/"}" else echo "$PWD" fi } Also add this command to enable expansion in prompt: shopt -s promptvars Then set your PS1 prompt to something like this: PS1='u@h:$(simplify_dir)$ '

Categories : Linux

LOCAL_DIR variable prepends the scripts current directory (totally not what I expect)
LOCAL_DIR="~/drupal-files/" The string is in quotes so there's pathname expansion, and the variable will contain the literal string. Remove the quotes. $ x="~/test"; echo $x ~/test $ x=~/test; echo $x /home/user/test

Categories : Bash

Opening a file in a module regardless of current working directory
You can use __file__. It keeps path to current python file. For example your bar.py file could contain something like this from os import path open(path.join(path.dirname(__file__), "database.db"))

Categories : Python

perl chdir not working, not changing the directory
You should move or die outside of chdir(...), i.e.: chdir("/etc") or die "cannot change: $! "; With what you have currently, the expression "/etc" or die "cannot change: $! " is evaluated first. Its result is "/etc" and die() never gets executed. or die() should be "applied to" chdir() call, not to its argument. Do print(cwd); to print current working directory. Don't forget to use Cwd; use Cwd; chdir("/etc") or die "cannot change: $! "; print(cwd);

Categories : Perl

does rbenv set the PATH variable to point to the correct ruby?
Did you execute all the step in the installation instructions https://github.com/sstephenson/rbenv? I.e. did you add the required snippets to your shell startup (.bash_profile) and so forth? If you followed the instructions, could you provide the output of rbenv versions and which -a ruby for a start? EDIT: rbenv rehash seems to be what generates the shims. This must be executed every time you install a new ruby version. How did you install the rubies? With ruby-build, as recommended in the installation instructions?

Categories : Ruby

Setting a working directory for a process to the exe's path?
Use ProcessStartInfo.WorkingDirectory in combination with Check if an executable exists in the windows path to determine the path to the executable. You might need to first check for relative paths, which I think should also handle absolute paths (I have not tested the following code, but it looks ok to me): string myAppPath = System.Reflection.Assembly.GetEntryAssembly().Location; if (File.Exists(Path.Combine(myAppPath, pathToExe))) { workDir = Path.GetDirectoryName(Path.Combine(myAppPath, pathToExe)); } else { // Use the referenced article to iterate thru System PATH to find the right path }

Categories : C#

assign a variable to all the files in a directory that have been modified in the last week through ruby?
You probably want to use select. Also, 604800 is the number of minutes in a week. I'm not sure if that is legitimate to use or not. files_sorted_by_time = Dir['*'].select { |f| ((Time.now - File.mtime(f)).to_i / 604800) < 7 }

Categories : Ruby

Shell script cannot be executed from some directories even though its directory is added to the "PATH" variable
You should add the complete path to your bin directory, not just bin. If bin is in your $HOME, you can add $HOME/bin or ~/bin.

Categories : Linux

What determines the current working directory of Tomcat Java process?
Did you see the variables? CATALINA_HOME: This represents the root of your Tomcat installation. When we say, "This information can be found in your CATALINA_HOME/README.txt file" we mean to look at the README.txt file at the root of your Tomcat install. CATALINA_BASE Optionally, Tomcat may be configured for multiple instances by defining $CATALINA_BASE for each instance. If multiple instances are not configured, CATALINA_BASE is the same as CATALINA_HOME. In the file apache-tomcat-7.0.42/bin/catalina.sh you will see: # Only set CATALINA_HOME if not already set [ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd` # Copy CATALINA_BASE from CATALINA_HOME if not already set [ -z "$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME"

Categories : Java

File path completion relative to the current file directory
Filename-completion is always done from the working directory. If you always want to do things relative to the current file, you can add set autochdir to your ~/.vimrc. You can change the working directory for the current window with :lcd %:p:h See :help 'autochdir', :help :lcd and :help filename-modifiers.

Categories : Node Js

How to get the actual path of a referenced .dll file from the current working assembly?
If the assembly is referenced by the project, you don't need to load it. You can get it by getting the Type of a class which is in that particular assembly. In general, doing Late-Binding on your own, isn't the best of an idea. We had some issues with that at our project and it's quite a lot of work to do it right. You could instead use some of the many different IoC-Containers, which will find the assembly and also the class for you. EDIT: I was maybe a bit confused, that I didn't think of it earlier. You can simply load an Assembly by it's name. Than it should find the assembly in all the referenced paths or the GAC. Further information can be found at MSDN

Categories : C#

Destroy path not working in Ruby on Rails
Updated answer. Your link_to declaration looks fine: = link_to "Delete", list_path(list), method: :delete, data: { confirm: 'Are you certain you want to delete this?' } It' likely that you do not have necessary javascript included in your layout file: # app/views/layouts/application.html.haml %head = javascript_include_tag "application" = csrf_meta_tag %> which is why the list_path is not able to execute the destroy action and is trying to execute the show action. If this does not work, then the problem is elsewhere that's preventing the javascript from being executed.

Categories : Ruby On Rails

Change my current working directory in Python to my external hard drive.
You are correct. >>> 'E:CollegeProject3dlife-gc-2013-dataset-hhi3dlife-gc-2013-dataset-hhi' 'E:\College\Projectx03dlife-gc-2013-dataset-hhix03dlife-gc-2013-dataset-hhi' Double the backslashes, use forward slashes, or use a raw string.

Categories : Python

Why does my python prompt disappear when changing working directory and importing?
Sounds like your module is actually doing work when it is imported. This is (usually) a bad idea. What you should do instead is put your setup code into a function, say setup() or initialize(), and then call it after importing: import earnings_download earnings_download.initialize()

Categories : Python

getScript jQuery path not working / Ruby on Rails
You can define action in controller like that: class LikesController < ApplicationController # another code def createLike # your action code end # another code end And you can call action like /likes/createLike. In the folder PATH_TO_APP/app/views/likes create a file createLike.html.erb - there is will be a createLike view Javascript files must be in the folder /PATH_TO_APP/public/javascripts And best way to include javascript file is a javascript_include_tag like: <%= javascript_include_tag "tile/tile.js" %> tile.js file must be is into the /PATH_TO_APP/public/javascripts/tile directory. And if you want to get javascript files with jQuery, you must put them in public/javascripts directory and call $.getScript('/javascripts/likes.js'); - there is a

Categories : Ruby On Rails

Website stops working after IIS deployment folder(physical path for virtual directory) is shared
I had the same issue. What I found is when you enable sharing on a directory it removes access permissions for the Appl Pool user and causes a failure. I had to manually add the --SERVER_NAME--IIS_IUSRS user with full permissions to the directory that was shared.

Categories : Asp Net

Why can I run this file packaged by Maven by specifying the path as argument but not by setting the path permanently in my path variable?
You'll need to add the storm dependencies to your classpath - it's currently not included because it is marked as 'provided' in the m2-pom.xml, change it to 'compile': <dependency> <groupId>storm</groupId> <artifactId>storm</artifactId> <version>0.8.2</version> <scope>compile</scope> </dependency>

Categories : Java

Passing variable as Hash element in Ruby not working
The colon in the string is what is screwing you up. 1.9.3p429 :003 > acc.to_sym :":credit" You need to make it just "credit" 1.9.3p429 :004 > acc = "credit" "credit" 1.9.3p429 :005 > acc.to_sym :credit 1.9.3p429 :006 > hello[acc.to_sym] "Testing"

Categories : Ruby

After I deleted a directory, it always prompts "shell-init error retrieving current directory getcwd solve" when log on bash
When opening a new shell or xterm, it's started in the working directory of the process that started it. If you e.g. cd /proc && xterm, the new terminal will place you in /proc. Whatever's starting your terminal had positioned itself in /home/desktop/zeno, and now all the terminals are trying to start there. If you make that process change directory (by rebooting, for example), the terminals will start in a directory that exists and you will no longer get this error.

Categories : Linux

Can chruby and chgems replace rvm's gemset?
I'll take a run at this question since I use Chruby and Chgems. I am on Mac OS X, and I have chruby installed via Homebrew. In my .bashrc file: source /usr/local/share/chruby/chruby.sh chruby ruby-2.0.0-p195 The source line is part of configuration for Chruby. The second line sets a default version of Ruby for my system (in my case Ruby 2.0.0). Note: As of Chruby 0.3.6 this belongs in .bashrc instead of .bash_profile. In my .bash_profile: source /usr/local/share/chruby/auto.sh This line sets Auto-switching feature in Chruby. I still have some projects using Ruby 1.9.3 so for those apps I have a .ruby-version file in the root of the app. with one line ruby-1.9.3 When you cd into the directory for your app, type chgems and then you can bundle install and what not. You can confi

Categories : Ruby

Django under IIS (with HeliconZoo) in virtual directory - urls resolver works with path without directory name
Finally, I've found what's wrong with it. Appeared that the reason for described behavior is a setting provided with default web.config file: <add name="django.root" value="%APPL_VIRTUAL_PATH%" /> After I removed it everything started working fine. Here is some info related to django.root variable applied to Apache.

Categories : Django

Directory.Delete(path, true) throws IOException "The directory is not empty"
It appears that info.EnumerateFiles was the issue. I got that idea from this answer. I switched that to info.GetFiles and I was then able to delete the directory after.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.