Solved

mkdir() function versus mkdir command

Posted on 2014-12-04
6
146 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
ID: 40480827
Are you capturing error messages? Are you using full path name while calling mkdir?
0
 

Author Comment

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

how to capture?
0
 
LVL 40

Accepted Solution

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

system("mkdir dir_name > /tmp/mylog 2> /tmp/myerror");
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 48

Expert Comment

by:Tintin
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

0
 
LVL 84

Expert Comment

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

Expert Comment

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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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 (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

839 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