#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    64
    Rep Power
    11

    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. #2
  3. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    perhaps using strcmp(type, "blabla") instead? just a guess :)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    64
    Rep Power
    11
    Can you please explain ? I've used this style code in another function and it works fine.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    64
    Rep Power
    11
    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 :D

IMN logo majestic logo threadwatch logo seochat tools logo