Unix "system " command

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • aki

    Unix "system " command

    Hello ,

    i want to use system commnad in my code to delete files in specified
    manner.
    but this way i am not able to delete files.
    Can somebody answer .



    i tried with this as following , but not working :(
    string omcid;
    string netype ;
    string nename ;

    //some stuff to get values inside these string variables

    cout<<"omcid"<< omcid<<endl; // here i printed the value it
    iscoming correct
    cout<<"netype"< <netype<<endl ;// here also
    cout<<"nename"< <nename<<endl ; // here also
    system( ("rm -f /path/" + omcid + '_' + netype + '_' + nename
    +"_*_trans.csv" ).c_str() ) ;

    thanks
    aki
  • santosh

    #2
    Re: Unix &quot;system &quot; command

    aki wrote:

    <news:comp.lang .c++>
    <news:comp.unix .programmer>

    Comment

    • aki

      #3
      Re: Unix &quot;system &quot; command

      On Aug 4, 5:20 pm, santosh <santosh....@gm ail.comwrote:
      aki wrote:
      >
      <news:comp.lang .c++>
      <news:comp.unix .programmer>
      it was due to inccorrect path ...
      now i is working fine..

      thanks
      Aki

      Comment

      • Martin Ambuhl

        #4
        Re: Unix &quot;system &quot; command

        aki wrote:
        Hello ,
        >
        i want to use system commnad in my code to delete files in specified
        manner.
        Your subject header and this sentence are both incorrect. system() is a
        C function, not a command, and certainly not a "Unix command".
        but this way i am not able to delete files.
        Use the C remove function. Surely this is in any elementary C textbook.

        #include <stdio.h>
        int remove(const char *filename); /* returns 0 for success, nonzero
        otherwise */

        If you don't have a standard C compiler, you could try the unix system
        function unlink(). If you do that, remember that it is non-standard,
        making your program not portable and making any enquiries about it
        off-topic here.

        You also need to find out what language you are using.
        Lines like
        string omcid;
        contain an undefined identifier 'string' in C, unless you have defined
        it somewhere. If you have, show it to us; don't make us guess what it
        means,

        and things like
        cout<<"omcid"<< omcid<<endl; // here i printed the value it
        iscoming correct
        have a number of problems. 'cout' and 'endl' are undefined in C, left
        shifting by a string constant has no meaning, and the '//' style comment
        has, as you can see, resulted in a broken line with the nonsensical line
        of code 'incoming correct' as a result.

        It appears that you have no idea what language you are using, or what
        functionality is available in it.

        Comment

        Working...