C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2003, 09:38 PM
ZeRO ZeRO is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 64 ZeRO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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;

}

Reply With Quote
  #2  
Old June 30th, 2003, 10:17 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
perhaps using strcmp(type, "blabla") instead? just a guess

Reply With Quote
  #3  
Old June 30th, 2003, 11:29 PM
ZeRO ZeRO is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 64 ZeRO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Can you please explain ? I've used this style code in another function and it works fine.

Reply With Quote
  #4  
Old June 30th, 2003, 11:38 PM
ZeRO ZeRO is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 64 ZeRO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Function does nothing, plz help.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT