mkdir

linux mkdir function can't authorize full permission

烈酒焚心 提交于 2019-11-29 04:56:46
I am testing the mkdir function to create a new directory: folder = mkdir("./linux", 511); or folder = mkdir("./linux", 0777); or folder = mkdir("./linux", S_IRWXU | S_IRWXG | S_IRWXO); As you can see, I try to authorize the full permission to the directory but here's what comes up with ls -l | grep linux : drwxr-xr-x 2 manuzhang manuzhang 4096 2012-01-04 06:53 linux why can't I authorize write permission for group and others? Updates : weird thing, as you guys told me I tried umask . It works with either umask(S_IWGRP) or umask(S_IWOTH) but fails with umask(S_IWGRP | S_IWOTH) , any ideas?

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

丶灬走出姿态 提交于 2019-11-29 03:39:32
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. 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 singer 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 check for exception for thread safety try: os.makedirs(directory_name) except OSError as err: if err.errno!=17

Android mkdir not making folder

冷暖自知 提交于 2019-11-29 02:58:38
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); setContentView(R.layout.main); File folder = new File(Environment.getExternalStorageDirectory () + "/tallgrass

PHP unable to create a directory with mkdir

久未见 提交于 2019-11-29 00:51:13
问题 I have a previously working PHP script that is able to create a directory with mkdir : $webfolder = "/var/www/html/images/user"; mkdir($webfolder, 0770); I made some changes to the permission setting of the folder /var/www/html/images which is now: drwxrwx---. myself apache system_u:object_r:httpd_sys_content_t:s0 images I think previously this folder was owned by apache . But since apache has the full privileges of read, write and execute as a user group, I wonder why it can't create a

os.mkdir(path) returns OSError when directory does not exist

老子叫甜甜 提交于 2019-11-28 21:12:26
I am calling os.mkdir to create a folder with a certain set of generated data. However, even though the path I specified has not been created, the os.mkdir(path) raises an OSError that the path already exists. For example, I call: os.mkdir(test) This call results in OSError: [Errno 17] File exists: 'test' even though I don't have a test directory or a file named test anywhere. NOTE: the actual path name I use is not "test" but something more obscure that I'm sure is not named anywhere. Help, please? Chris Johnson Greg's answer is correct but doesn't go far enough. OSError has sub-error

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

谁都会走 提交于 2019-11-28 15:44:58
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. KarstenF How about this one-liner (in bash): mkdir --parents ./some/path/; mv yourfile.txt $_ Breaking that down: mkdir --parents

mkdir fails with tilde on OS X in C?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 11:00:13
问题 I'm porting a C library to OSX which haven't given me much of a headache until now. In the next function: int createDirectory( char *directory ){ int error; error = mkdir(directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if( error < 0 ){ if( errno != EEXIST ){ return errno; } } return error; } No matter what directory is, mkdir() always fails with EPERM (Operation not permitted). I'm not sure if the xcode executable is sandboxed or if I'm missing something, but every path I pass to the

One command to create and change directory

不打扰是莪最后的温柔 提交于 2019-11-28 07:12:01
I'm searching for just one command — nothing with && or | — that creates a directory and then immediately changes your current directory to the newly-created directory. (This is a question someone got for his exams of "linux-usage", he made a new command that did that, but that didn't give him the points.) This is on a debian server if that matters. Marian Zburlea I believe you are looking for this: mkdir project1 && cd "$_" define a bash function for that purpose in your $HOME/.bashrc e.g. function mkdcd () { mkdir "$1" && cd "$1" } then type mkdcd foodir in your interactive shell So stricto

PHP mkdir and apache ownership

筅森魡賤 提交于 2019-11-28 04:04:51
问题 Is there a way to set php running under apache to create folders with the folder owned by the owner of the program that creates it instead of being owned by apache? Using word press it creates new folders to upload into but these are owned by apache.apache and not by the site that they are running in. This also happens using ostickets. For now we have to SSH into the server and chmod the folder, but it would seem there would be a setting somewhere to override the ownership outside of any

Bash mkdir and subfolders [duplicate]

 ̄綄美尐妖づ 提交于 2019-11-28 03:25:49
This question already has an answer here: How to create nonexistent subdirectories recursively using Bash? 3 answers Why I can't do something like this? mkdir folder/subfolder/ in order to achive this I have to do: mkdir folder cd folder mkdir subfolder Is there a better way to do it? You can: mkdir -p folder/subfolder The -p flag causes any parent directories to be created if necessary. To create multiple sub-folders mkdir -p parentfolder/{subfolder1,subfolder2,subfolder3} FWIW, Poor mans security folder (to protect a public shared folder from little prying eyes ;) ) mkdir -p {0..9}/{0..9}/{0