w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Display the names of all .txt documents within the current (or specified) directory
This should work: File folder = new File("path/to/txt/folder"); File[] files = folder.listFiles(); File[] txtFiles = new File[files.length]; int count = 0; for(File file : files) { if(file.getAbsolutePath().endsWith(".txt")) { txtFiles[count] = file; count++; } } It should be pretty self explanatory, you just need to know folder.listFiles(). To trim down the txtFiles[] array use Array.copyOf. File[] finalFiles = Array.copyOf(txtFiles, count); From the docs: Copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length.

Categories : Java

python inside vim to obtain file list from current directory
You have simply imported the glob module not the glob function and have tried calling the module as a function. !p from glob import glob #Change this line as shown cwd = vim.eval("getcwd()") # or maybe vim.eval("expand('%:h')") snip.rv = " ".join([ " <files>%s</files>" % file for file in glob(cwd + "/*")]) This is at least the initial problem.

Categories : Python

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

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

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

JavaScript - How to display the current URL as a link in current window?
You can do something like this.. Maybe you can improvise on this... <a href="#" id="link" target="_blank">Link</a> <script type="text/javascript"> window.onload = function(){ document.getElementById("link").href = window.location.toString(); } </script>

Categories : Javascript

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

Purpose of Curly Brace Usage of C Code found in Linux (include/linux/list.h)?
This is a GNU language extension known as a statement expression; it's not standard C.

Categories : C

not found [No such file or directory] error, even though the file present in that directory on RH Linux 6.2
Enter this: ls -ls /data/RAIL/rpo402/db/upgrade List the output for the file and look at it's permissions. Make sure the file isn't empty. Make sure the file has permissions to be executed as a shell. chmod +x upgrade_db.ksh Look at the first line of the file, make sure it has a proper header for a shell script. Maybe Korn Shell requires the shell declaration in the header. Check dmesg to see if there are any error messages, perhaps the file system and check inodes.

Categories : Linux

How to use the "current" in jCoverflip so that the current item is always in the middle of a dynamically generated list?
The syntax for getting the length for the list is $('#flip').jcoverflip('length'); but this is only available once the .jcoverflip has been instantiated on your list and you need this value when you instantiate .jcoverflip on your list, so it's a bit of a catch 22 as I see it. What I did to solve it was to get the number of li items from #flip like this var middle = Math.round($('#flip li').length / 2); and then I instantiated .jcoverflip $('#flip').jcoverflip({ current: middle }); I used Math.round in case the number of items in the list is an odd number. Jcoverflip won't work if you put in a float as current.

Categories : Jquery

Linux C read a directory
I found this code here in Stack Overflow (How can I get a list of files in a directory using C or C++?), that helped me a lot in understanding how it works: #include <dirent.h> #include <stdio.h> #include <string.h> int main(){ DIR* dirFile = opendir( "." ); struct dirent* hFile; if ( dirFile ) { while (( hFile = readdir( dirFile )) != NULL ) { if ( !strcmp( hFile->d_name, "." )) continue; if ( !strcmp( hFile->d_name, ".." )) continue; // in linux hidden files all start with '.' if ( gIgnoreHidden && ( hFile->d_name[0] == '.' )) continue; // dirFile.name is the name of the file. Do whatever string comparison // you want here. Something like: if ( strstr( hFile->d_name, ".c" ))

Categories : C

Make current OpenGL context on Linux
That 'GLXDrawable' is the X11 window for which you have got the context. If you are using qt, I would have assumed it would have provided a 'myWindow.makeCurrent()' function, or something to the effect. You can make a window using XCreateWindow (there is also a function for making a basic window with less options). Before this, you will need to have got a connection to the display using XOpenDisplay. I have been very short on the details here, as there is a lot steps for getting an OpenGL Context in an X11 window, and whilst not hard, does involve a lot of error checking. I suggest you make use of a library that handles this for you.

Categories : Linux

iOS - dirent.h - current directory name
See `NSFileManager as it provides the standard iOS interface to the filesystem. https://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html As well, you should understand this thoroughly. https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemProgrammingGuide.pdf (See the iOS section)

Categories : IOS

How do I obtain and use the current directory of the exe?
Use: File.Copy(SelFolder & "Resource.zip", progDirectory) Instead of: My.Computer.FileSystem.WriteAllBytes(SelFolder & "Resource.zip", progDirectory, False)

Categories : Dotnet

Get current batchfile directory
System read-only variable %CD% keeps the path of the caller of the batch, not the batch file location. You can get the name of the batch script itself as typed by the user with %0 (e.g. scriptsmybatch.bat). Parameter extensions can be applied to this so %~dp0 will return the Drive and Path to the batch script (e.g. W:scripts) and %~f0 will return the full pathname (e.g. W:scriptsmybatch.cmd). You can refer to other files in the same folder as the batch script by using this syntax: CALL %0..SecondBatch.cmd This can even be used in a subroutine, Echo %0 will give the call label but, echo "%~nx0" will give you the filename of the batch script. When the %0 variable is expanded, the result is enclosed in quotation marks. More on batch parameters.

Categories : Batch File

Linux directory permission inheritance
The way permissions affect paths is explained in the path_resolution man page: http://linux.die.net/man/2/path_resolution The only permission on folder A that matters is the search (execute) permission: if you don't have it you can't descend to folder B. Other than that there is no relation between permissions of A and B, for example if A is read-only and B is not, or even if you don't even have read permission to A, you still can create and delete files in B.

Categories : Linux

No such file or directory error in linux
This line: #!/bin/bash set -o pipefail cd #<----- here! echo Testing node splitting [1/2], should take seconds ../pathwaytab2daifg needs_split_1.pathway.tab needs_split_1.cfg | diff needs_split_1.out - || exit 1 is changing the directory to ~/, which is the default argument of cd if you don't pass a path to it (see here). You could fix the script to work from anywhere if you like, by giving cd an absolute path i.e. changing that cd line to cd /home/hora/Paradigm/testdata.

Categories : Linux

linux/module.h No such file or Directory
You're missing the Linux kernel headers which allow you to compile code against the Linux kernel. To install just the headers in Ubuntu: $ sudo apt-get install linux-headers-$(uname -r) To install the entire Linux kernel source in Ubuntu: $ sudo apt-get install linux-source Note that you should use the kernel headers that match the kernel you are running.

Categories : Linux

No Such File or Directory Error In Linux
You're getting the error because you're trying to run it as root. Run as user devuser (from within the /home/devuser/Documents/Sublime Text 2 directory) and it should be OK. I think your original error came from the fact that you were trying to run ./sublime_text from within the /etc directory, and it wasn't installed there. The ./ part of your command means "run the file named thus-and-such in the current directory".

Categories : Linux

jQuery/JS: Get current URL parent directory
Fiddle var a = "http://www.site.com/example/index.html"; var b = a.substring(0, a.lastIndexOf('/'))+"/";

Categories : Javascript

How to Keep Ace from Looking for Themes and Modes in Current Directory?
I find with Ace and MVC Bundling and Minification, I need to set the basePath in the ace configuration using an absolute reference. ace.config.set("basePath", "/Scripts/FullPathToMy/AceEditorDirectory"); It's probably not the best solution, but it should get you on your way.

Categories : C#

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

mod_rewrite rewritebase current directory
this does exactly that, through it looks too scary to use http://www.zeilenwechsel.de/it/articles/8/Using-mod_rewrite-in-.htaccess-files-without-knowing-the-RewriteBase.html googled by mod_rewrite htaccess directory current directory

Categories : Htaccess

Zip together all HTML files under current directory
What about this? find /your/path/ -type f -name "*.html" | xargs zip all_html_files.zip looks for all .html files under the directory /your/path (change it for yours). Then, pipes the result to xargs, which creates the zip file. Edit To junk the paths, add -j option: find /your/path/ -type f -name "*.html" | xargs zip -j all_html_files.zip

Categories : Linux

obtaining Current directory in VC++ forms
You are passing the address of the pointer to Convert::ToString(). pwd is an array and using the variable name without an array subscript automatically decays to a pointer. You want to use either Convert::ToString(pwd) or Convert::ToString(&pwd[0])

Categories : Visual C++

log4j.xml in current directory not found
For Eclipse testing in Maven the easiest thing I've found to do is to put the log4j.xml in src/test/resources. It will be added to the classpath when running unit tests, etc. When we actually install our application at a customer site we place the file in /etc/... and specify it with -Dlog4j.configuration. My best guess as to why the current directory part isn't working for you is that Eclipse is probably setting the current directory to something other than what you think it is. Try following the instructions here to print the current working directory and check it matches what you think. UPDATE: Almost forgot. When you specify -jar the classpath options (-cp -classpath) are ignored. -jar Execute a program encapsulated in a JAR file. The first argument is the name of a J

Categories : Java

NPM Installs Package Outside Current Directory
If the node_modules directory doesn't exist in your current directory, NPM will look for it in the higher directories until it finds it. So, if the parent directory has a node_modules directory, NPM will assume that's where it is to install modules. A quick way around this is to create an empty node_modules directory where you want the modules to be placed.

Categories : Node Js

What is the difference between these ways of getting current directory?
They all give the same result They certainly don’t. currentDir and dir both give you the current working directory – i.e. by default the directory your executable was run from (but it can be changed during the execution). By contrast, appBaseDir and path get the directory which contains the executing assembly’s file. To illustrate how they differ, consider that you have an executable which sits in C:araz.exe. Now I can execute the application by entering the following chain of commands in a terminal: $ md C:foo $ cd C:foo $ ..araz.exe Now the current working directory is C:foo but the application’s base directory is C:ar. There exist analogous means of setting the working directory for other methods of launching an application (e.g. via a shortcut icon or programmat

Categories : C#

Display username when adding comments My SQL cannot record the username, only display the current login user
In your code the $conn is not initialized anywhere. Initialize it like this before trying the query. $conn = mysqli_connect("localhost", "my_user", "my_password", "world"); Check the php manual for proper usage. Hope that helps :)

Categories : PHP

select option: display current date at first time, display last selected date in future
Change the list of arguments and make the second if condition an else if. The meaning of the second condition is, the current month should be only selected if the month has not already being submitted. if($i==$this->form['months']) { print '<option value="'.$i.'" selected>'.$months[$i-1].'</option>'; } else if ($i==date("m") && @empty($this->form['months'])) { print '<option value="'.$i.'" selected>'.$months[$i-1].'</option>'; } else { print '<option value="'.$i.'" >'.$months[$i-1].'</option>'; }

Categories : PHP

retrieve part of Linux directory path
You can directly use System.getEnv(String) method. If you want parts of MY_HOME by going 3 levels up then you can probably do: String logPath = myHome + "/../../../logs"; OR to get first 2 parts of path: String arr[] = myHome.split("/"); String logPath=""; if (arr.length > 2) logPath = arr[0] + '/' + arr[1] + "/logs"; System.out.println(logPath); // mydir/myproject/logs

Categories : Java

GTK+-3.0-dev No Such File Or Directory on compile (Linux Mint/gcc)
OK, the guys over at linuxquestions got me straightened out. ` != ' (backtick is not the same as single quote) I should have used backticks instead of the quote, also could have used $() $ gcc simple.c -o simple $(pkg-config --args) I'll go read a manual on the command line... :/ as for the first problem (why pkg-config --libs gtk+-3.0) gave me a "package gtk+3.0 was not found in the pkg-config search path", I think I must have only had libgtk-3-dev installed and not installed gtk+3.0.

Categories : C

Apply directory permissions to all new subdirectories in linux
Most unix command come with a recursive option. In this case: -R, --recursive It seems like you are trying to use this, but you have -Rm. That is not the correct option. I think what you need is: sudo setfacl -R -m g:users:rwX,d:g:users:rwX index/ I typically use chmod instead of setfacl. chmod -R 777 *

Categories : Linux

linux execvp ; ls cannot access |, No such file or directory
ls -l | less is actually a shell command line that consists of two processes connected by a pipe. The execvp() call can only spawn a single process. If you want to do this from your program, you must invoke the shell explicitly - either by using the system() call, or by changing the command line to sh -c 'ls -l | less'. Your word array should look like this: word[0] = "sh" word[1] = "-c" word[2] = "ls -l | less" word[3] = NULL [EDIT] Alternatively, you could do what the shell is doing internally: spawn two processes and connect them with a pipe. This would involve using the fork(), pipe(), dup2() and execve() calls. However, invoking the shell is much less work, and since less is an interactive program anyway, you don't need to worry about performance that much: anything that takes les

Categories : C

x86 linux cr3 register dereference (how can I get to a page directory?)
The contents of the CR3 register are for the CPU, not for the kernel. Software always uses virtual addresses. If you want to access the page tables, you should use the helper macros in <asm/page.h>; for details, see Page Table Management (although it's somewhat outdated).

Categories : Linux

Linux zip a directory excluding some internal directories
It's not an error, it's a warning. Archives containing absolute paths to files are a security risk. Imagine an archive containing /etc/passwd. If you insist upon having the absolute paths in the archive, use the -P option: -P, --absolute-names don't strip leading `/'s from file names

Categories : Linux

System.IO.Directory.Exists() use with both Windows and Linux
Windows is quite tolerant about this. You can use the forward slash and it will understand. If you don't want to take the chance it might get confused (I'm not 100% sure Windows always understands this), you can use Path.DirectorySeparatorChar

Categories : C#

linux - cannot view directory created from java
This does not work because ~ is expanded by your shell, bash or sh or whatever. This doesn't work from Java. You have created a directory called ~ in your working directory. You need to get the user's home directory from the system property user.home and build your path from that. final File dir = new File(System.getProperty("user.home"), "tempDir");

Categories : Java

PHP script to move a directory from one Linux server to another?
there are many ways to do this but the easiest seems to be to send your cmd with php's exec or passthru function. http://php.net/manual/en/function.exec.php http://www.php.net/manual/en/function.passthru.php Warning When allowing user-supplied data to be passed to this function, use escapeshellarg() or escapeshellcmd() to ensure that users cannot trick the system into executing arbitrary commands.

Categories : PHP



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