|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Function does nothing, plz help.
I wrote this function as part of a larger program im writing. But upon excution it does nothing, no errors, no output, nothing. Just kicks me back to the shell. Excuting the command manually gives output so Its the function. I've checked in ps aux to confirm that it indeed does nothing. Please help
![]() Code:
int service (const std::string& type, const std::string& servicename) {
if (type == "start"){
std::string cmd = "/etc/init.d/"+ servicename +" start";
system(cmd.c_str());
}
else if (type == "stop"){
std::string cmd = "/etc/init.d/"+ servicename +" stop";
system(cmd.c_str());
}
else if (type == "restart"){
std::string cmd = "/etc/init.d/"+ servicename +" restart";
system(cmd.c_str());
}
return 0;
}
|
|
#2
|
||||
|
||||
|
perhaps using strcmp(type, "blabla") instead? just a guess
![]() |
|
#3
|
|||
|
|||
|
Can you please explain ? I've used this style code in another function and it works fine.
|
|
#4
|
|||
|
|||
|
Ok, I did a little more debugging and found a silly bug in my program. I was using the wrong variable names in the main file ^_^. I didnt notice it earlier as the other function takes anything as input. Thanks anyways
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Function does nothing, plz help. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|