mkdir

How to use bash to test directory limits of filesystem

泪湿孤枕 提交于 2019-12-10 23:13:04
问题 I need to test how many directories and files I can create on a filesystem (network mounted and local (usb) drives). I now use this bash line: for i in {0..999999}; do mkdir -p $i; pushd $i; done I know that it probably can be done better and I'd like to know how to. (in bash, not too complicated) 回答1: while (true); do mkdir a cd a done Creates something like ./a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/ ... 回答2: Any file/directory is represented using an inode, take a look at df -i and you

What's a POSIX function for creating a temporary directory securely?

心已入冬 提交于 2019-12-10 17:38:06
问题 This question was migrated from Information Security Stack Exchange because it can be answered on Stack Overflow. Migrated 7 years ago . For the task of creating a temporary directory in /tmp , how would one choose between mkdtemp , mkstemp , etc., for portable code? 回答1: I presume you need to create a temporary directory inside a directory where other users may have write permission. As an administrator, you should set things up so that each user has its own TMPDIR (e.g. with pam-tmpdir — or

PHP mkdir() and fopen() does not work - permissions problem? umask problem?

只谈情不闲聊 提交于 2019-12-10 13:56:57
问题 The following PHP script fails to create the directory. It will also fail to create the file (when the directory already exists). ini_set('error_reporting', E_ALL); define('ABSPATH', $_SERVER['DOCUMENT_ROOT']); echo ABSPATH . '<br /><br />'; $dir_to_make = ABSPATH . '/aaatest'; $file_to_make = ABSPATH . '/aaatest/aaatest.txt'; echo umask() . '<br />'; mkdir($dir_to_make) or die('could not create directory'); fopen($file_to_make) or die('could not open/create file'); The umask() is returning a

mkdir not working in PHP

僤鯓⒐⒋嵵緔 提交于 2019-12-10 13:29:53
问题 Have been pulling out my hair for the past 2 hours on this and am sure I am doing something really stupid. <?php mkdir("blah", 0777); ?> This works through the command line and the folder gets created. But the same thing doesn't work when I try to run it through the browser. Any file permission issues? 回答1: Could it possibly be that while running under the command line, the script inherits your permissions, but when running from the browser it doesn't? In that case you would want to make your

Plink cmd.exe mkdir with a space doesn't work

折月煮酒 提交于 2019-12-10 11:29:25
问题 I'm using plink on a windows 7 desktop to create a folder a on windows 2008 server. The server uses pragmaSSH to allow the SSH connection and everything works just fine there. The directory I want to create has a space in it and that is where my problem starts. I have a basic plink command that works like this plink.exe -i privatekey.ppk user@server cmd.exe /c mkdir "c:\asdfasdf" but changing that command to this fails. so the space is for sure my issue. plink.exe -i privatekey.ppk user

Why mkdir fails with recursive option set true?

旧城冷巷雨未停 提交于 2019-12-10 02:54:07
问题 I run the following code: mkdir('mnt/1',0777,true); mkdir('mnt/a',0777); Directory "a" is created, while directory "1" is not, page prints warning. Warning: mkdir(): File exists in /home/bitrix/www/php_test.php on line 3 I have full permissions on directory mnt for user apache is running: drwxr-xr-x 1 bitrix bitrix 4096 Nov 28 10:10 mnt PHP version - PHP 5.3.3. Apache version 2.2.15. Any ideas, why mkdir fails with recursive option set to true? Update! Well I cleared the folder, made the

How to use mkdirs in a thread safe manner in Java?

馋奶兔 提交于 2019-12-09 09:49:49
问题 After experiencing issues with mkdirs() and poking around the interwebs, I get the impression that there are thread safety issues with mkdirs(). Is there a way to ensure the directories are properly created when it is possible that multiple threads might be trying to create similar file structures? Thanks (In my case I will be using this on Android) 回答1: Okay, I know this has been inactive for a while, but I thought perhaps there was a simple solution. The article you linked in the comments

bash create dir with sequential numbers

自闭症网瘾萝莉.ら 提交于 2019-12-09 03:56:49
问题 I am creating a script to run on OS X which will be run often by a novice user, and so want to protect a directory structure by creating a fresh one each time with an n+1 over the last: target001 with the next run creating target002 I have so far: lastDir=$(find /tmp/target* | tail -1 | cut -c 6-) let n=$n+1 mkdir "$lastDir""$n" However, the math isn't working here. 回答1: No pipes and subprocesses: targets=( /tmp/target* ) # all dirs in an array lastdir=${targets[@]: (-1):1} # select filename

Files not being uploaded in dynamically created folders/subfolders

血红的双手。 提交于 2019-12-08 18:55:28
i need help to solve this problem Files not being uploaded in dynamically created folders/subfolders! creating a dynamically subfolder using input type text and when i uploaded file moved to uploads folders but not moved to subfolder which is create using input type text? but dynamically creating function working fine and also showing me folder which is typed in the textbox into the upload folder Here My Code //creating dynamically subfolders $folder = $_POST['folder']; foreach( $folder as $key => $value){ $dirPath = 'uploads/'.$value; $result = mkdir($dirPath); } if ($result == '1') { //file

Using mkdir -m -p and chown together correctly

我的梦境 提交于 2019-12-08 15:15:17
问题 I would like to create a directory using a bash script and then set the mode to 00755 at the same time mkdir -p -m=00755 "/dir/dir2" Is this the correct way of using them together and can I also add chown command to the same line while creating them? 回答1: It goes a little like this: install -d -m 0755 -o someuser -g somegroup /dir/dir2 回答2: If you want to set the owner during creation, you can simply impersonate as this user, using sudo for example: sudo -uTHE_USER mkdir -p -m=00755 "/dir