w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
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

Resque job returning with error: "No such file or directory - getcwd"
I started having this same issue on my production environment. After some investigation I found that this was caused by my resque workers failing to be properly restarted on each capistrano deployment.

Categories : Ruby On Rails

Python interactive shell running copy.py on current directory?
When Python imports a module, the module search path order is: the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH). the installation-dependent default. Now, when raising an exception, Python runs specific code. Any code that tries to import the copy Python module will instead import your module and print the string in it. This is why you shouldn't use names that are also names of standard Python modules.

Categories : Python

Extract .tar File to Current Directory Automatically with Shell Script
You can try: -C, --directory DIR change to directory DIR and $(dirname "$x") for file directory for x in in /home/davidwright/attachments/*/*.tar do echo "extracting $x" tar -xvf "$x" -C "$(dirname "$x")" done

Categories : Bash

What does "mkdir /mnt 0700 shell shell" do in init.rc..?
The commands in the init.rc file are special language used by the android init process. The syntax is loosely described in a readme file in the AOSP source code: https://android.googlesource.com/platform/system/core/+/master/init/readme.txt by in particular the command you are asking about will create a directory called "/mnt" with the unix permissions "0700" owned by the user "shell" and the group "shell". I hope that helps.

Categories : Android

Directory or File contain space error in Shell Script
Classic; don't use for .. in, use find "$INDIR" -type f | while read file; do echo "Encrypting $file" "$PROJECT_DIR/crypt" -e -k $ENC_KEY -i "$file" -o "$OUTDIR/`basename "$(dirname ${file})"`/`basename "$file"`" done

Categories : Osx

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

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

Error while running a batch with a file as parameter that does not belong to the current directory
Well, the use of %~f1 does NOT guarantee that the file exists! If the parameter given to the Batch file includes the full path, then %~f1 just return the same information and does not check for the existence of the file. I suggest you to test the Batch file below: @ echo off echo "%~f1" if exist "%~f1" ( findstr /r "I.*=" "%~f1" >outer.TXT ) else ( echo File does NOT exist! )

Categories : Batch File

php preg_replace find — replace with —
You should not use preg_replace to replace a constant string. Just use str_replace instead. $description = str_replace("—","—", $description);

Categories : PHP

Init process interaction with shell cripts
You can find explanations of what it does in different documentation: http://www.centos.org/docs/5/html/5.1/Installation_Guide/s2-boot-init-shutdown-init.html http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4 and you can find its source code over there: init.h init.c basically, init as process 1, has for role to fork() every application on your system. If you boot linux with the command line init=/bin/sh at boot time, process 1 forked by the kernel will be a shell. The sysvinit program makes it a bit more easy to handle a complex boot. It adds the concept of runlevels, define basic environment etc.. so that makes it easy to boot a system and have many services, and not only a shell. All that part is well explained in the documentations I gave you. Does an

Categories : Linux

Git: says origin already exists on "NEW" (init) repository, using shell but installed github for windows
I've been running into the same issue, and I think I've figured it out finally. GitHub for windows installs a version of PortableGit in /Users/<username>/AppData/GitHub. In the PortableGit directory, under /etc, there's a gitconfig file. This is the system config. It defines "origin" and "upstream", presumably with defaults that are meaningful to GitHub. I can't say for sure, but I started noticing this problem in the latest few updates of the GitHub for Windows client. Sadly, the release notes don't point to anything probative and the Windows client isn't open-source so it's hard to tell. I've sent a message to their support address, so I'll update here if I hear anything back. Edit: GitHub support responded saying this is a known issue and will be fixed soon.

Categories : GIT

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

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

How to print the name of my current directory's parent directory
You can use ${PWD%/*}: $ echo $PWD /home/me/test/t $ echo ${PWD%/*} /home/me/test As the expression ${string%substring} Strips shortest match of $substring from back of $string (reference).

Categories : Shell

Retrieving current url with angular in a rails app
When configuring your routes with your $routeProvider, you can specify variable names that can then be retrieved inside your controller. example app.js: angular.module('myApp', []) .config(function ($routeProvider) { $routeProvider .when('/items/:item_id', { templateUrl: 'views/item.html', controller: 'ItemCtrl' }) .otherwise({ redirectTo: '/' }); }); And then you can resolve your item id in your controller by injecting the $routeParams angular object in your controller like so: ItemCtrl.js: angular.module('myApp') .controller('ItemCtrl', function ($scope, $routeParams) { var itemId = $routeParams.item_id; });

Categories : Angularjs

EF 4.1 Issue retrieving original and current values
That is an odd way of trying to get values... try this. concretePerson.Quantity will be the local copy of the entity so it will have whichever value you assigned to it. In the first foreach you are actually modifying each of the items in the collection (even if it is not saved to the database yet it is still in memory, otherwise how would EF know what to save to the database?). In the second you are actually checking the same collection to see if entities have been modified (which they have) and then getting the current value. However the current value for quantity will be the same as .quantity because you have modified the entity. If you check the original value for modified entries you will see that it is different. Basically CurrentValue is the value of the in memory entity (if you

Categories : Entity Framework

the image is not retrieving from document directory
1 - What is the result of paths, documentsDirectory and getImagePath is correct or not. 2 - Try set the img filename manually (ie : @"1.png") and check if img is loaded correctly 3 - At the other hand, check the file if it exists in documentsDirectory path (also included by project) NSURL *url = [NSURL fileURLWithPath:path]; Check if file is exists in your documents directory or not if([[NSFileManager defaultManager] fileExistsAtPath:path]) NSURL *url = [NSURL fileURLWithPath:path]; Also check in your documents directory if the image is getting saved or not. You are given the name of the image like this image = [UIImage imageNamed:@"1.png"]; so if you are repeating this line your images will be overwritten in documents directory. You can also put a check here BOOL success = [

Categories : IOS

Get the current directory name via php script in another directory
I am not 100% sure of your questions, but it sounds like you are looking for the URL/Directory of the page you are currently on, not the directory of the header? What about: $_SERVER['PHP_SELF']; $_SERVER['REQUEST_URI']; $_SERVER['SCRIPT_NAME']; $_SERVER['SCRIPT_FILENAME']; $_SERVER['DOCUMENT_ROOT']; Those all give info about the current file open by the server based on the HTTP request it received.

Categories : PHP

Retrieving current position causes my Android app to force close
I'm guessing line 23 of your MainActivity is this: Toast.makeText(MainActivity.this, "Latitude -> "+Double.toString(loc.getLatitude()) Put in a null check after this line Location loc = lm.getLastKnownLocation(lm.NETWORK_PROVIDER); It is possible there is no last known location from the network provider and loc is null. Try this: LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // connect to the GPS location service Location loc = lm.getLastKnownLocation(lm.NETWORK_PROVIDER); //Try to get it from the GPS_PROVIDER if (loc == null) { loc = lm.getLastKnownLocation(lm.GPS_PROVIDER); } if (loc != null){ Toast.makeText(MainActivity.this, "Latitude -> "+Double.toStri

Categories : Android

iOS persistence: storing and retrieving items in directory
You aren't strictly 'doing' anything wrong. It's your expectations that are wrong. The method you're using (contentsOfDirectoryAtPath:) Performs a shallow search of the specified directory and returns the paths of any contained items. If you want to load the file back into memory you need to: Decide which file you want Get the full path to the file (directory path and file name) Load the file (if it's a dictionary, dictionaryWithContentsOfFile:)

Categories : IOS

System.IO.Directory.GetFiles() not retrieving any files in C#?
Based on your comment "The directory has 2 non-empty subdirectories", the Directory.GetFiles(string) overload does not recursively check subdirectories and would not pick up those files. Instead try using Directory.GetFiles(dir_path, "*", SearchOption.AllDirectories) which will grab files in subdirectories as well.

Categories : C#

Retrieving a Single File and the Behavior of Directory.GetFiles C#
I am assuming you want the contents of the file (if you just want the file name and need to check for existance a different solution will be required). files[count] = File.ReadAllText(Path.Combine(@"C:\_projectsExampleProjectsrc", currentTableName)); And a couple other suggestions: Don't initialize your variables with bogus data, = new string[] {} can be removed Don't use count as an indexer, it is confusing (count is a property of the array after all) Use Path.Combine when joining paths. It is much easier as it handles the for you.

Categories : C#

Determine the current user's shell
$ awk -F: '$1 == "myusername" {print $NF}' /etc/passwd /bin/zsh Or, if you have the username in shell variable var: awk -F: -v u=$var '$1 == u {print $NF}' /etc/passwd This assumes /etc/passwd is locally complete (as opposed to being NIS served; see your /etc/nsswitch.conf and respective man page).

Categories : Shell

Get reference to the current instance of Shell window
You are setting up the container wrong. This tells Unity to give you back the specific instance of Shell when an IShell is requested: Container.RegisterInstance<IShell>(new Shell()); And this tells it to resolve an instance of Shell (not IShell) -- which it happily does, returning a different instance than before: return Container.Resolve<Shell>(); As a result, when you later resolve an IShell from the container you get back a shell window that has not been used at all and its window handle has not been created. Do this instead: protected override System.Windows.DependencyObject CreateShell() { var shell = new Shell(); Container.RegisterInstance<IShell>(shell); return shell; }

Categories : C#

C: List aliases of current shell (not subshell!)
I just downloaded and built GNU time on my Mac. To my surprise and chagrin, it doesn't read aliases from the parent bash, whereas the built-in time does. $ alias frodo=ls $ ./time frodo ./time: cannot run frodo: No such file or directory Command exited with non-zero status 127 0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 819200maxresident)k 0inputs+0outputs (0major+59minor)pagefaults 0swaps $ time frodo AUTHORS INSTALL Makefile.in config.cache configure* error.o getopt.o getpagesize.h mkinstalldirs* resuse.h stamp-vti time.c time.texi version.texi COPYING Makefile NEWS config.log configure.in getopt.c getopt1.c install-sh* port.h resuse.o texinfo.tex time.info version.c wait.h ChangeLog Makefile.am READM

Categories : C

How to execute a shell command in the current cmd.exe context?
When you start cmd.exe, you can set its environment path: var psi = new ProcessStartInfo("cmd.exe"); psi.UseShellExecute = false; psi.EnvironmentVariables["path"] = "mypath"; Process.Start(psi); Please prefer comment before downvote.

Categories : C#

Source a file into current shell using Ruby
A Ruby script (or any program, for that matter) cannot alter the shell that started it, so you’ll either have to run source ~/.custom_rc after running the script, or have the script also output the contents of the file to stdout, in which case you could do source <(ruby genrc.rb) or eval "$(ruby genrc.rb)" The script could also instead output the path to the written file, and you could do: source $(ruby genrc.rb)

Categories : Ruby

CakePHP Shell issue with my directory structure
The file is in the wrong folder Compare to Cake, whereas your shell is in: /app/Console/HelloShell.php Cake is expecting: /app/Console/Command/HelloShell.php That's also why it doesn't show up as an available shell when typing simply Console/cake. Be careful with your paths Especially if you have multiple applications, it's not that good an idea to play around with paths, better to just run the application-specific cli command: $ cd /apps/www.website1.com $ Console/cake Welcome to CakePHP v2.x.x Console ... This is unambiguous, whereas it's quite easy to type cake in the wrong dir and wonder why things don't work as expected.

Categories : Cakephp

How to change git shell's start directory in windows 7
According the article below (in the "Posh-Git and PowerShell" section) you should be able to create a DocumentsWindowsPowerShellGitHub.PowerShell_profile.ps1 file that will start when your GitHub PowerShell starts. In that file you can add the Set-Location c:path o epo command. For what it's worth, in case anyone comes across this but has a Bash shell, adding the command cd /path/to/repo to ~/.basrc should do the trick. http://haacked.com/archive/2012/05/21/introducing-github-for-windows.aspx

Categories : GIT

Change Active directory in Shell Script
Following is the problem line in your script: exit Remove it, and execute your script by either saying: source runIt.sh or . runIt.sh You might have observed that your session would have exited upon invoking the script using either of the two forms mentioned above. This is because using source or . cause the script to run in the same shell.

Categories : Bash

Shell Script to copy all files in a directory to a specified folder
I guess this what you are looking for : #!/bin/bash dir=$(cat a.txt) for i in $(ls -l|grep -v "^[dt]"|awk '{print $9}') do cp $i $dir/$i"_"$(date +%Y%m%d%H%M%S) done I assumed that a.txt contains only the name of the destination directory. If there are other entries, you should add some filter to the first statement(using grep or awk). NB: I used full time stamp(YYYYMMDDHHmmss) instead of your YYYYMMDDmmss as it doesn't seem logical.

Categories : Shell

Is it possible to make some shell calls automatically when entering a directory?
You can use an alias: $ echo 'echo "execute something for $PWD"' > tests/.cdrc $ _cd() { cd $1 [ -r .cdrc ] && . .cdrc } this function first change to the dir specified as argument, check if the file .cdrc is readable and source it. $ alias cd=_cd Then $ cd tests execute something for /path/to/tests

Categories : Bash

Unable to copy files from directory in shell script
change cp -r /Users/ajay/Documents/ServerObserverRepo/* /WebServer/Documents/ServerObserver/ to cp -r /Users/ajay/Documents/ServerObserverRepo/* /WebServer/Documents/ServerObserver/.

Categories : Shell

directory is not creating while running bash shell script in php
Check with which user's permissions it's run. You could echo the output of "whoami" (bash) command to know with wich user is used to run the script. If it's executed, for example, with the "www-data" user (ubuntu's [and maybe others] default httpd user), then it may not have the rights to create a directory in your user's home folder.

Categories : PHP

Shell Scripting:copy any missing files in a sub directory
DEFAULT_PNG='/path/to/your/1x1.png' if [[ $1 ]]; then echo "Arguments passed"; if [[ -d $1 ]]; then for curFile in "$1/"abc_{01..36}.png; do if ! [[ -f $curFile ]]; then cp -- "$DEFAULT_PNG" "$curFile" fi done else echo 'Supplied argument is not a directory'; fi else echo 'No arguments passed'; fi Read about bash brace expansion After you have edited your question I start to understand that you want something different... So, if I got it right this time, here is a script that works for subfolders DEFAULT_PNG='/path/to/your/1x1.png' if [[ $1 ]]; then echo "Arguments passed"; if [[ -d $1 ]]; then for curSubdir in "$1/"*; do if [[ -d $curSubdir ]]; then #skip

Categories : Bash

Shell script to poll a directory and stop upon an event
$ declare -f tillStopfile tillStopfile () { cd receive_dir [[ -d ../send_dir ]] || mkdir ../send_dir while true; do date +%m-%d-%Y-%H:%M:%S for f in * do mv "$f" ../send_dir [[ $f == "stopfile" ]] && break 2 done sleep 3 done } $ Improvements while true ... break # easier to control this loop cd receive_dir # why not run in the "receive_dir" factor date out of inner loop # unless you need to see each time-stamp? added suggested "sleep" # pick a suitable inteval Run: $ tillStopfile 2>/dev/null # suppresses ls error messages

Categories : Bash

Applescript. How to resolve preset dyndns to current IP and use it as a variable in a shell command
There's a command line utility "host" that will do this for you. I made a little handler ipForHostName() to run the host command and parse the text to return only the ip address... set hostName to "myhost.dyndns.org" set ipAddress to ipForHostName(hostName) do shell script "'/Vine Server.app/OSXvnc-server' -connectHost " & quoted form of ipAddress & " -connectPort 5905" on ipForHostName(hostName) try do shell script "/usr/bin/host " & quoted form of hostName & " | grep "has address"" return last word of result on error return hostName end try end ipForHostName

Categories : Osx

Unable to bind to port 80, but running on the current shell works without any issues
you need root access to bind to lower ports like port 80. rvmsudo executes in root context and therefore it works. cap task executes in a normal user context (probably deploy) depending on your configuration. you should add sudo ability to cap deploy user and make sure your cap task uses sudo to start unicorn.

Categories : Ruby On Rails

running multiple process in current shell (using {} ) with atleast one command to be run as background
As & is a valid command delimiter, there is no need for ;. { echo "42" & sleep 3; }

Categories : Bash



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