Solved

write  to a process

Posted on 2004-04-08
9
165 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

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

 

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!

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

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

790 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