mkdir() function versus mkdir command

Posted on 2014-12-04
Last Modified: 2014-12-20

system("mkdir dir_name");

Open in new window

does not create any folder but,
mkdir("dir_name", 0770);

Open in new window

successfully creates

Question by:Nusrat Nuriyev
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 40

Expert Comment

ID: 40480827
Are you capturing error messages? Are you using full path name while calling mkdir?

Author Comment

by:Nusrat Nuriyev
ID: 40482444
Are you using full path name while calling mkdir?

how to capture?
LVL 40

Accepted Solution

omarfarid earned 500 total points
ID: 40483786
try to redirect the errors to a file:

system("mkdir dir_name > /tmp/mylog 2> /tmp/myerror");
Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

LVL 48

Expert Comment

ID: 40485916
As per the system documentation, use:

@args = ("mkdir", "/path/to/dir");
system(@args) == 0 or die "system @args failed: $?"

Open in new window

LVL 84

Expert Comment

ID: 40485960
Is this written in Perl or C?
LVL 48

Expert Comment

ID: 40486052
Whoops.  Didn't see the topics.   My last post is for Perl only.

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question