Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

mkdir() function versus mkdir command

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
Nusrat Nuriyev
Asked:
Nusrat Nuriyev
1 Solution
 
omarfaridCommented:
Are you capturing error messages? Are you using full path name while calling mkdir?
0
 
Nusrat NuriyevAuthor Commented:
Are you using full path name while calling mkdir?
Sure.

how to capture?
0
 
omarfaridCommented:
try to redirect the errors to a file:

system("mkdir dir_name > /tmp/mylog 2> /tmp/myerror");
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
TintinCommented:
As per the system documentation, use:

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

Open in new window

0
 
ozoCommented:
Is this written in Perl or C?
0
 
TintinCommented:
Whoops.  Didn't see the topics.   My last post is for Perl only.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now