Re: file deletion in a directory with some conditions .
On Aug 4, 2:07 pm, aki <akhileshrawat...@gmail.com> wrote:
On Aug 1, 11:17 pm, James Kanze <james.ka...@gmail.com> wrote:
On Aug 1, 6:20 pm, aki <akhileshrawat...@gmail.com> wrote:
On Aug 1, 12:23 pm, Michael DOUBEZ <michael.dou...@free.fr> wrote:
[...]
Well for system command path cannot be a variable,
Of course it can be. It can be an expression, just like any
other function argument.
i tested it. as this will not work
system("rm -f /path/OMCID_NETYPE_NENAME_*_trans.csv");
because OMCID , NETYPE, NENAME are variables.
So you need a different expression. Something like:
system( ("rm -f /path/" + OMCIDE + '_' + NETYPE + '_' +
NENAME + "_*_trans.swv").c_str() ) ;
i tried with this as following , but not working :(
string omcid;
string netype ;
string nename ;
//some stuff to get values inside the string variables
TrDebug<<"omcid"<<omcid<<endl; // here i printed the value it is
coming correct
TrDebug<<"netype"<<netype<<endl;// here also
TrDebug<<"nename"<<nename<<endl; // here also
system( ("rm -f /path/" + omcid + '_' + netype + '_' + nename +
"_*_trans.csv").c_str() ) ;
And how is it not working? It should compile (as long as one of
the first two operands in the sequence of +'s is a string, which
seems to be the case). What does system() return? Otherwise:
try redirecting the output of rm (both standard out and standard
error) to a file, and see what it contains.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34