Solved

write  to a process

Posted on 2004-04-08
9
164 Views
Last Modified: 2010-04-22
sir ,

mkdir rath
 will create a directory  .
with out using system() ,i hve to  
make a directory called xxx

 ie
     int  main(int argc ,char *argv[])
     {
     }
i  hve to pass directory name as an argument.
0
Comment
Question by:karana
9 Comments
 
LVL 12

Expert Comment

by:stefan73
ID: 10783345
Hi karana,
Like this:

int main(int argc,char** argv){
    if(argc!=2){
        [error... not exactly one argument]
    }

    mkdir(argv[0]);
}

Cheers,
Stefan
0
 
LVL 12

Accepted Solution

by:
stefan73 earned 50 total points
ID: 10783350
> mkdir(argv[0]);
...should read
mkdir(argv[1]);

argv[0] is the program name itself, not the first argument.

Stefan
0
 

Author Comment

by:karana
ID: 10791529
sir ,

 i  hve to use popen()
0
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.

 

Expert Comment

by:ray_pro2
ID: 10794355
If you intension is just creation of the directory 'xxx', add this line to the body of your main( ):

mkdir(argv[1]);

--supply the directory name as the first argument in the command line following the program name, while running the program.
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10822623
karana,
> popen()
popen is very similar to system, it also has a full shell:

FILE* f=popen("mkdir your_dir","r");
/* Now you can parse mkdir's stdout via freads from f. But as mkdir is mute, not much use here */
pclose(f);

You could parse mkdirs stderr by redirecting it:
FILE* f=popen("mkdir your_dir 2>&1","r");

Then you can catch errors.

Stefan
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10822633
karana,
You have tons of open old questions - please close them.

Stefan
0
 
LVL 1

Expert Comment

by:fyf7262284
ID: 10934795
ok!the function of "mkdir" is right to you!
"man 2 mkdir"
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
File system unmounted 3 156
rhel6 C system() call to zip to archive has problems 25 241
How to trace the cause of Out Of Memory issues 8 71
Problem to start Neon 20 106
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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