Opening multiple Terminals using C++

I'm trying to have my C++ program open a new terminal and execute that program. But the problem is that the program requires root to run. So far i have this
1
2
3
4
5
6
7
void airodump()
{

	string cmd= "gnome-terminal -e \"su - -c \" airodump-ng ath0\"";
	
	system(cmd.c_str());
}

Now the problem is that the last arg "ath0" isnt getting passed though correctly. I was wondering if there was any way to create a new terminal session besides the way ive tried.
Are you missing a double quote?
 
string cmd= "gnome-terminal -e \"su\" - -c \" airodump-ng ath0\"";

No, i'm beginning to think it isnt possible with that command because it calls 2 commands that each have arguments and the double quote will close the statement.
With what you suggested i get this :
1
2
Unknown option -c
Run 'gnome-terminal --help' to see a full list of available command line options.

What distribution are you using? You may want to check out consolehelper(8).
Fedora 10 x64. consolehelper(8) doesnt work for me . Is there a way to just open up a 2nd terminal and be able to run commands in it using C++, instead of the way i'm trying? Like having a function to execute commands in one terminal and another one in the second.
Make your executable setuid root?
This is what i get then
1
2
(gnome-terminal:1682): GnomeUI-WARNING **: While connecting to session manager:
None of the authentication protocols specified are supported.
I think I will just write a bash script and have the program execute it, its not what I really want but it will be a work around till I can find another way.
In your original string, you have THREE escaped double-quotes. That's why I added one (now that I look back, in kind of a pointless place). So maybe try adding/removing escaped double-quotes. Here are some possibilities.

1
2
string cmd= "gnome-terminal -e su - -c \"airodump-ng ath0\"";
string cmd= "gnome-terminal -e su - -c airodump-ng ath0";

The first one gives:
Unknown option -c airodump-ng ath0
The second gives:
Unknown option -c

The problem is gnome-terminal runs the su command and the su command to run airodump-ng ath0. I do not think that it is possible to run both of them from one single line the way i'm trying to do.
Last edited on
Have you tried other quoting possibilities, like this:

string cmd= "gnome-terminal -e \"su - -c airodump-ng ath0\"";
Topic archived. No new replies allowed.