How to execute .sh file from different directory though a c++ Program

i was trying to write a short c++ code to choose different conky's.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
switch(choice)
{
case 1:		system("killall -9 conky");
		system("conky -c ~/.conky_config_files/.conky_grey/conkyrc_grey");
		break;

case 2:		system("killall -9 conky");
		system("conky -c ~/.conkycolors/conkyrc");
		break;

case 3:		system("killall -9 conky");
		system("conky -c ~/.conky_config_files/.my_conkyrc/conkyrc");
		break;

case 4:		system("killall -9 conky");
		system("conky -c ~/.conky_config_files/.Conkydidi/conkyrc");
		break;

case 5:		system("killall -9 conky");
	//	execl("~/.conky_config_files/.GoldnGrey/conky.sh","conky.sh", NULL);
	//	system("chmod 777 ~/.conky_config_files/.GoldnGrey/conky.sh");
	//	system("bash ~/.conky_config_files/.GoldnGrey/conky.sh");	
		break;

default:	cout<<"\nAgain.\n";
		goto again;
}


My case 5 is not working, tried almost evrything on internet.
I dont know much bash coding. In this program i was trying to execute conky.sh from any directory.

Also, i want to hide the terminal on which i execute this program.

Any help?!!?!?

PS: i know case 5 is commented.
Are you sure your script is marked as executable and contains #!/bin/bash in the first line?
And what's the content of this mysterious
conky.sh
?
A killall command makes this seem like a malicious thread to me. I remember seeing a Youtube video where a guy taught how to make a program and cover up that you were killing apps so the user would have to reboot the computer to fix it.
A killall command makes this seem like a malicious thread to me.
When you pass a process name to killall, it doesn't kill all. Are we going to start verifying the intentions of everyone that posts a question that could remotely be malicious? Not trying to flame you, I just dont see the point, I save my paranoia for the real world where things are actually dangerous.
This is what I saw a few days ago that popped into my head when I read this question:

http://www.youtube.com/watch?v=FFPaHBdaSX0
Thanks Everyone

Well i found the solution,
Yes shadow123 that script has #!/bin/bash in the beginning. What fixed the code is
1
2
		system("chmod +x ~/.conky_config_files/.GoldnGrey/conky.sh");
		system("~/.conky_config_files/.GoldnGrey/conky.sh");


And for them who dont know commands : http://ss64.com/bash/killall.html

BHXSpecter, you should spend time with bash commands.
Last edited on
And for them who dont know commands : http://ss64.com/bash/killall.html

I'm fully aware of what the killall command is and is why I posted that video and commented on seeming malicious. We don't know what conky is nor do we know what is in the script so for all we know you are killing a process to sneak and run a script that does something malicious to a computer. I'm always weary when someone starts asking about process killing and script running from a program.
There is a clear difference in the usage of killall by unkn00wn and the guy in the video. Did you notice he is restarting the process after killing it? I dont know what conky is either (maybe http://en.wikipedia.org/wiki/Conky_%28software%29 ) and maybe he is doing something malicious, but I have no proof, and neither do you. There are a lot of commands that can be used maliciously, doesn't mean every usage is malicious.

@unkn00wn
Unless the shell script is being created on the fly there shouldn't be a reason to chmod it in code, do it once in a terminal and your set.
BHXSpecter, you should spend time with bash commands.

I've been using Linux distros for 15 years and I'm use to bash commands. Also been programming for 14 years. I only boot up Windows for gaming.

Did you notice he is restarting the process after killing it?.....maybe he is doing something malicious, but I have no proof, and neither do you. There are a lot of commands that can be used maliciously, doesn't mean every usage is malicious.

He is restarting a process, but we have no proof that the script he is calling is the original. Anyway, I never said he was malicious, just that this thread seemed malicious. I know it isn't malicious though because of the chmod call in his code. You would have to run the program with the switch in it as root for it to affect any root owned files/scripts.
Topic archived. No new replies allowed.