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

Ignore a directory except specific files in a subdirectory in Git
Allowing everything under install after ignoring everything else (*) has the form * !/dev !/dev/host !/dev/host/mail !/dev/host/mail/htdocs !/dev/host/mail/htdocs/install !/dev/host/mail/htdocs/install/* But this also allows stray files at higher levels of the tree. That means adding the additional ignore rules from your question. The short answer is what you have is necessary. It is an odd repository structure, so git does not optimize for it.

Categories : GIT

How to copy pictures from directory and subdirectory to another directory?
You have private String path; private File[] images = new File("C:/Users/Public/Pictures/Sample Pictures"+"/").listFiles(); so at start path is null. Now you need to know that fields are initialized before constructors code, so if you change images to new File(path+"/").listFiles(); it will be the same as changing it to new File(null+"/").listFiles(); so it will produce new File("null/").listFiles(); To solve that problem try invoking images = new File(path+"/").listFiles(); when path will be set to correct value, so probably after getPath method.

Categories : Java

How to get name of directory (NOT subdirectory) and filename with PHP?
Try DirectoryIterator,here is an example $path = dirname(dirname(__FILE__)); $it = new DirectoryIterator($path); while($it->valid()){ /*....*/ echo $it->getPathname().'">'.$it->getBasename(); $it->next();//i forgot this just now }

Categories : PHP

Why is .pyc file created sometimes in same directory and sometimes in __pycache__ subdirectory?
Python 3 has changed how the bytecode (.pyc) files are stored. Python 2 uses the convention of putting them in the same directory, but for Python 3 the developers decided to reduce clutter by putting them all in a separate directory. This also made support for Python implementations other than CPython easier, as each implementation could have its own .pyc files in the __pycache__ directory rather than overwriting those from other implementations.

Categories : Python

How to access a file in a directory from other directory, when both are in same parent directory with HTML
if dir1 and dir2 are in the same parent directory then this is how you access 2.html from 1.html: <a href="../dir2/2.html">link to 2.html</a> hope it helped :)

Categories : HTML

Redirect from a subdirectory to the parent without symbolic links
If the rules need to be in the htaccess file in the /m/ directory, you may be able to do something like this: RewriteEngine On RewriteCond %{REQUEST_URI} ^/m/ RewriteRule ^(.*)$ /$1 [L] Otherwise, you can add this rule to the htaccess file in your document root (/): RewriteEngine On RewriteRule ^m/(.*)$ /$1 [L]

Categories : Apache

Find top-level directory from subdirectory on Linux in Python
Find the real path based on the relative path of "up three directories," and extract the last part of that real path. [Edit: In response to your comment I have revised this. In my opinion it is getting complex enough that your chain of dirname's is better. At least it is easy to understand what it happening.] from os import path as p _, ci_root = p.split(p.abspath(p.join(__file__, '../../..')))

Categories : Python

URL Rewriting domain to use subdirectory as root; still shows that directory in URL in Analytics?
Your rules do nothing to prevent people from directly accessing /c/whatever. If you want to prevent that, you need to add an extra rule: RewriteCond %{THE_REQUEST} /c/ RewriteRule ^c/(.*)$ /$1 [L,R=301]

Categories : PHP

Redirect an entire directory on a WP site to a new domain, with a few subdirectory exceptions
I think you just want something simple: RewriteRule ^2012/$ http://www.newdomain.com/blog/ [L,R=301] RewriteRule ^2012/subdirectory/?$ http://www.newdomain.com/blog/subdirectory/ [L,R=301] Or maybe: RewriteRule ^2012/(.*)$ http://www.newdomain.com/blog/$1 [L,R=301] These rules need to be before any wordpress rules in your htaccess file.

Categories : PHP

Extracting directory/subdirectory name from absolute path in a batch script
SET MYPATH=publicshareproductsapps123.456OSfile for %%i in ("%MYPATH%") do SET FIRST=%%~nxi&SET MYPATH=%%~dpi SET MYPATH=%MYPATH:~0,-1% for %%i in ("%MYPATH%") do SET SECOND=%%~nxi echo %FIRST% -- echoes OSFile echo %SECOND% -- echoes 123.456 The first FOR statement extracts the filename+extension (%%~nxi), then sets MYPATH to the remainder of the path (drive letter + path). "SET MYPATH=%MYPATH:~0,-1%" removes the trailing backslash. The second FOR statement extracts the last element from MYPATH, which is now the directory.

Categories : Batch File

SFTP Upload via Python and Pythonista with Paramiko. Can't create directory/subdirectory
You run into the same problem with FTP, you can't mkdir /some/long/path, you have to cd / mkdir some # ignore errors if it exists cd some mkdir long # ignore errors if it exists cd long mkdir path # ignore errors if it exists cd path I'm guessing that the historical reason for this model is to provide a simple boolean SUCCEED/FAIL for any command issued by the client. Having some fuzzy error like 'Couldn't make directory /some/long/path because directory /some/long doesn't exist' would be a pain in the ass to handle on the client side. In looking at the SFTP protocol spec re: filenames ( http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#page-15 ), it's unclear to me if clients are expected to understand '/' as a path separator in the context of making a directory - since you

Categories : Python

Use custom 404 page for specific subdirectory only
The problem your having is because of the way the WordPress rewrite system works. The WordPress .htaccess sends all requests (that dont actually exist except index.php) through the index.php file in the WordPress root directory. If any request is made for a file named index.php it will also get sent through the root WordPress index.php. A simple solution would be to rename the index.php file in /subdirectory to default.php. Depending on your hosting setup it might work by just doing that. If it doesn't you can add a 301 redirect to your .htaccess that points www.domain.com/subdirectory to www.domain.com/subdirectory/default.php Redirect 301 /subdirectory http://domain.com/subdirectory/default.php The .htaccess file will be located in your public_html or root public web directory. (fro

Categories : PHP

Redirect homepage to specific subdirectory
Insert this rule on top of all the rules just below RewriteBase line: RewriteCond %{HTTP_HOST} ^members.slateadvisers.com$ [NC] RewriteRule ^$ ?action=registeruser&subscription=1 [L,R=301]

Categories : Wordpress

Access denied when trying to execute a .exe in %AppData%
I am not JAVA user but isn't it 32 vs. 64 bit issue ? on 64 bit Windows error code 5 usually means that executable is not 64 bit compatible sometimes this is the case even when executable need to access only some (older win) system directory which does not exist anymore To prove this try to use your executable in command line. if you can manage to get it work there than it is different issue. If not find executable for your OS. Another possibility is that the file has to be physically present on some drive. you wrote that you has it as temporary. not shore what it means for JAVA if it only copy it to some file and delete after use than its OK but if it is only in memory somewhere than that could be problem if executable need access to itself To prove this just copy the file to some

Categories : Java

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

Access to this directory is denied
The only possible reason I can think of is you are not really the WoopyCat user, here is the correct way to get the path based of the currently running user. var roamingFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //This equals the AppDataRoaming folder for the current user Directory.Move(Path.Combine(roamingFolder, ".minecraft"), Path.Combine(roamingFolder,currentUser));

Categories : C#

Directory Listing Denied On Mvc 4
If this works locally, and you're getting these results after publishing the site, the only conceivable thing that I could see occurring is the host doesn't have ASP.NET MVC 4 installed and running on their server. One other possibility is that it's not registered properly. It's almost behaving like ASP.NET isn't registered with IIS. have your admin run aspnet_regiis.

Categories : Dotnet

Get parent directory's parent directory name in java
Have a look at http://developer.android.com/reference/java/io/File.html#getParentFile() Applying this twice will probably get you the right directory. But note that you program might or might not be allowed to go there, based on the settings in the file system and the context your code runs in.

Categories : Java

Getting parent value in an iframe gives permission denied?
You seem to be violating the same origin policy restriction. You cannot access the iframe contents if both the parent and the iframe are hosted on the same domain. So basically if you want this to work you will have to host PassValueIFrame.html on http://somedomain.com.

Categories : Javascript

Why do I get the error "bash: ./a.out: Permission denied" when I execute a C program in Linux mint 15
I think, you are trying to run your program on an NTFS partition, different from the one on which Mint is installed. Try to compile the program in your ext4 partition and generate the a.out there. It should run.

Categories : C

How to redirect all sub-directory pages to parent directory?
Add this to your .htaccess file RedirectMatch 301 ^/folder/$ http://example.com/folder What this basically does in corresponding to your question is redirect anything (be it sub directories, or files) inside the folder directory to your parent folder.

Categories : PHP

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

linux checking number of files subdirectory - providing wrong variable result when subdirectory searching for does not exist
You are getting error messages that you shoud fix. Cd is failing because you are not allowed to change into a non-existent directory. Your shell will just stay in the directory it was in. It looks like you know how to test for directory existence, so you should just do that more to avoid trying to go into non-existent directories.

Categories : Linux

I'm trying to compress some files from one directory to another but I'm getting access denied on one of the directories why?
It doesn't work because you pass a directory name for the second parameter to CompressDirectory. You should pass a file name like.... string output = Path.Combine(zippedFileDirectory, "MyZipFile.7z"); ..... compressor.CompressDirectory(source, output);

Categories : C#

root directory IOError: [Errno 13] Permission denied:
You already answered your own question: You do not have the permission to do so. No matter if you use sh, bash, python, C, erlang or a rubber-hose attack. Either run your script with a user owning the necessary permissions or grant yourself access to the file.

Categories : Python

fopen() Permission Denied despite having correct file directory
Maybe, you have no premissions to acces the file. One of the answet, is that, you must change CHMOD to e.g. 777. You can co it with your ftp explorer or with PHP. chmod("/somedir/somefile", 777);

Categories : PHP

getting the full filenames from all top directory files in a specific directory and suppressing the occuring error
Did I understand correctly that you only need the File-names with directory-names. This code works for me, no elevations needed. private void button1_Click(object sender, EventArgs e) { string folder = @"C:windowsprefetch"; string filemask = @"*.pf"; string[] filelist = Directory.GetFiles(folder, (filemask)); //now use filelist[i] for any operations. }

Categories : C#

In jQuery, how to remove all occurrences of a CSS class, and add it once to a specific sibling of the tag's parent's parent?
Try this $('a.active').closest('ul') .prev() .addClass('ui-state-active') .siblings('h3') .removeClass('ui-state-active');

Categories : Jquery

Access to path [Destination Address] is denied - when creating a new directory - VB.NET
I am not sure of you have the error in the CreateDirectory call or afterward. I am sure that the FileUpload control doesn't have a SaveAs method and this is on the PostedFile object and that you need to pass a FileName not a Directory name Dim directoryPath As String = Server.MapPath("~/bussnisses") If Not Directory.Exists(directoryPath) Then Directory.CreateDirectory(directoryPath) End If Dim destFile = Path.GetFileName(FileUpload1.PostedFile.FileName) destFile = Path.Combine(directoryPath, destFile) FileUpload1.PostedFile.SaveAs(destFile) Label1.Text = "complete"

Categories : Asp Net

Aws EC2 EBS setup gives error ls: cannot open directory /mnt/my-data/: permission denied
When you create /mnt/my-data using the above two commands, the directory ends up being owned by root. In order to change this: sudo chown -R ec2-user:ec2-user /mnt/my-data (Assuming ec2-user is your current user.) Now it should work and you should be able to use that directory as your regular user.

Categories : Amazon

Copy files from source directory to target directory and exclude specific file types from specified directories
This is one way to do it $SourceDirectory = 'C:Source' $DestinationDirectory = 'C:Destination' $ExcludeExtentions = '*.txt*', '*.xml*' $ExcludeSubDirectory = 'C:Sourcead_directory1', 'C:Sourcead_directory2' Get-ChildItem $SourceDirectory -Recurse -Exclude $ExcludeExtentions | Where-Object { $ExcludeSubDirectory -notcontains $_.DirectoryName } | Copy-Item -Destination $DestinationDirectory Your best friend here is Where-Object, or where. It takes a scriptblock as parameter and uses that scriptblock to validate each object that goes through pipeline. Only objects that make script return $true are passed through Where-Object. Also, take a look at the object that represents a file you get from Get-ChildItem. It has Name, Directory and DirectoryName containing pieces of file's FullNam

Categories : File

rsync recursively and exclude content of specific directory, not the directory
In recent versions of rsync, you can use the -F option and put a file ".rsync-filter" in the directory src, containing: - dir1/*** That seemed to work for me. I'm assuming that your hierarchy above is all under "src/".

Categories : Linux

Downloading a file from a subdirectory retains the subdirectory name
In the line: Response.AddHeader( "Content-Disposition", "attachment; filename="" + Request.QueryString["File"] + """ ); Remove Request.QueryString["File"] and put your own file name.

Categories : C#

Execute any X file in a directory every X seconds
metacode: forever read content of directory (depending on your operating system, f.e. DosFindFirst) for each content which is a .bat (and not empty) call system sleep (inside or out side the for each depending on your needs)

Categories : C

Django media directory needs execute permission
Setting execute on a directory means something very different from x on a file. From the excellent answer over at Unix.SE When applying permissions to directories on Linux, the permission bits have different meanings than on regular files. [...] The execute bit allows the affected user to enter the directory, and access files and directories inside Setting x on the directory seems to be (I'm not a security expert) benign, and apparently required, so nothing to worry about. x on the files is what you want to avoid.

Categories : Django

How to execute PowerShell script against all CSV files in a directory?
If I understand what you're asking, just use a file glob and pipe the results to Import-CSV **. Use a Foreach-Object loop to capture the base name of each CSV file to use in naming the output files. Get-ChildItem .*.csv | Foreach-Object { $basename = $_.BaseName import-csv $_ | ConvertTo-Json -Compress | Foreach {$_ -creplace '""NULL""','null'} | Out-File ".$basename.json" } BTW, there's no "s" at the end of Get-ChildItem.

Categories : Powershell

Parent directory in R
I assume you mean parent directory of R's working directory? The simplest solution is probably as follows. wd <- getwd() setwd("..") parent <- getwd() setwd(wd) This saves the working directory, changes it to its parent, gets the result in parent, and resets the working directory again. This saves having to deal with the vagaries of root directories, home directories, and other OS-specific features, which would probably require a bunch of fiddling with regexes.

Categories : R

How to execute files added to .bashrc out of current directory?
Here is the solution: Composer showed an error that I was running the CGI version of php (stupid I know, I know). That was because I had an symlink in my bin dir to the cgi version. I changed the link it shows now to the CLI version of php. Now it works :)

Categories : Linux

How to copy and execute a file using Active Directory to a client?
You can use Login scripts or GPOs to deploy Software, but a Software deployment System is of course better... If you have MSIs (and optionaly transforms and patches) you can easily publish them in a GPO. Watch a Video here.

Categories : C#



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