Solved

mkdir() function versus mkdir command

Posted on 2014-12-04
6
136 Views
Last Modified: 2014-12-20
Hello,

system("mkdir dir_name");

Open in new window

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

Open in new window

successfully creates

Regards,
Nusrat
0
Comment
Question by:Nusrat Nuriyev
6 Comments
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
Are you capturing error messages? Are you using full path name while calling mkdir?
0
 

Author Comment

by:Nusrat Nuriyev
Comment Utility
Are you using full path name while calling mkdir?
Sure.

how to capture?
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
Comment Utility
try to redirect the errors to a file:

system("mkdir dir_name > /tmp/mylog 2> /tmp/myerror");
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 48

Expert Comment

by:Tintin
Comment Utility
As per the system documentation, use:

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

Open in new window

0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Is this written in Perl or C?
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
Whoops.  Didn't see the topics.   My last post is for Perl only.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now