mkdir

Vim: Creating parent directories on save

对着背影说爱祢 提交于 2019-11-28 02:53:25
If I invoke vim foo/bar/somefile but foo/bar don't already exist, Vim refuses to save. I know I could switch to a shell or do :!mkdir foo/bar from Vim but I'm lazy :) Is there a way to make Vim do that automatically when it saves the buffer? augroup BWCCreateDir autocmd! autocmd BufWritePre * if expand("<afile>")!~#'^\w\+:/' && !isdirectory(expand("%:h")) | execute "silent! !mkdir -p ".shellescape(expand('%:h'), 1) | redraw! | endif augroup END Note the conditions: expand("<afile>")!~#'^\w\+:/' will prevent vim from creating directories for files like ftp://* and !isdirectory will prevent

mkdir command not found in bash script

送分小仙女□ 提交于 2019-11-28 02:50:47
问题 I don't know why I get error while running this simple script: #!/bin/bash read -p "Please enter directory name: " DIR read -p "Please enter the path: " PATH mkdir -p "$PATH/$DIR" line 7: mkdir: command not found 回答1: Don't use the variable PATH . This variable contains a list of directories to search for executable programs. Since you're replacing it, the script can no longer find the mkdir program. In general, avoid using variables that are all uppercase, these are often used as parameters

PHP mkdir 0777 fail chmod 0777 works

£可爱£侵袭症+ 提交于 2019-11-28 00:45:09
问题 using PHP 5.2.14, this is what happens [user@VE213 public_html]$ php -r "mkdir('directory', 0777);" [user@VE213 public_html]$ ls -lt drwxrwxr-x 2 rankranger rankranger 4096 Dec 8 17:28 directory [user@VE213 public_html]$ php -r "chmod('directory', 0777);" [user@VE213 public_html]$ ls -lt drwxrwxrwx 2 rankranger rankranger 4096 Dec 8 17:28 directory Did not find any related bugs in the php bug list, any idea? 回答1: $old = umask(0); mkdir($dir,0777); umask($old); Read this, http://php.net/manual

How to find a reason when mkdir fails from PHP?

我怕爱的太早我们不能终老 提交于 2019-11-27 22:51:29
PHP's mkdir function only returns true and false. Problem is when it returns false. If I'm running with error reporting enabled, I see the error message on the screen. I can also see the error message in the Apache log. But I'd like to grab the text of the message and do something else with it (ex. send to myself via IM). How do I get the error text? Update: Following Ayman's idea, I came to this: function error_handler($errno, $errstr) { global $last_error; $last_error = $errstr; } set_error_handler('error_handler'); if (!mkdir('/somedir')) echo "MKDIR failed, reason: $last_error\n"; restore

File.mkdir or mkdirs return false - Reason?

这一生的挚爱 提交于 2019-11-27 21:01:31
Why file.mkdir is returning false? Google indicates that there could be several reasons (e.g. security, permissions, pathname, etc). My questions: How to find the exact reason of returning false? If security/permissions is a reason, then why is SecurityException not thrown? If security/permissions is a reason, then why is SecurityException NOT thrown (which is mentioned in javadoc)? A SecurityException is thrown when you don't have JVM-level permission to do something, not OS-level Is there a way to find the exact reason why of returning false? No, AFAIK. The only way to know would be to check

Is there a way to make mv create the directory to be moved to if it doesn't exist?

心已入冬 提交于 2019-11-27 19:46:32
问题 So, if I'm in my home directory and I want to move foo.c to ~/bar/baz/foo.c , but those directories don't exist, is there some way to have those directories automatically created, so that you would only have to type mv foo.c ~/bar/baz/ and everything would work out? It seems like you could alias mv to a simple bash script that would check if those directories existed and if not would call mkdir and then mv, but I thought I'd check to see if anyone had a better idea. 回答1: How about this one

How to run os.mkdir() with -p option in Python?

谁说胖子不能爱 提交于 2019-11-27 17:41:45
问题 I want to run mkdir command as: mkdir -p directory_name What's the method to do that in Python? os.mkdir(directory_name [, -p]) didn't work for me. 回答1: You can try this: # top of the file import os import errno # the actual code try: os.makedirs(directory_name) except OSError as exc: if exc.errno == errno.EEXIST and os.path.isdir(directory_name): pass 回答2: Something like this: if not os.path.exists(directory_name): os.makedirs(directory_name) UPD: as it is said in a comments you need to

Android mkdir not making folder

孤街浪徒 提交于 2019-11-27 17:15:28
问题 Tonight I am currently having issues doing something that I thought would be simple... making a folder in /mnt/sdcard. I have set the follow permission: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> My Main.java has the following to make the folder: public class Main extends TabActivity { static int index = 1; private static final String TAG = "Main"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

How do I include parameters in a bash alias? [duplicate]

白昼怎懂夜的黑 提交于 2019-11-27 12:46:26
This question already has an answer here: Make a Bash alias that takes a parameter? 13 answers Trying to create: alias mcd="mkdir $1; cd $1" Getting: $ mcd foo usage: mkdir [-pv] [-m mode] directory ... -bash: foo: command not found What am I doing wrong? An alias can only substitute the first word of a command with some arbitrary text. It can not use parameters. You can instead use a shell function: mcd() { test -e "$1" || mkdir "$1" cd "$1" } 来源: https://stackoverflow.com/questions/1821495/how-do-i-include-parameters-in-a-bash-alias

Vim: Creating parent directories on save

六月ゝ 毕业季﹏ 提交于 2019-11-27 04:59:31
问题 If I invoke vim foo/bar/somefile but foo/bar don't already exist, Vim refuses to save. I know I could switch to a shell or do :!mkdir foo/bar from Vim but I'm lazy :) Is there a way to make Vim do that automatically when it saves the buffer? 回答1: augroup BWCCreateDir autocmd! autocmd BufWritePre * if expand("<afile>")!~#'^\w\+:/' && !isdirectory(expand("%:h")) | execute "silent! !mkdir -p ".shellescape(expand('%:h'), 1) | redraw! | endif augroup END Note the conditions: expand("<afile>")!~#'^