Re: Shell Access with C++ Recommendations
On Nov 16, 7:43 pm, xander.grespe...@gmail.com wrote:
On Nov 16, 1:59 am, James Kanze <james.ka...@gmail.com> wrote:
I'm not sure what you mean by "shell access" services. C++
has a standard function, system() which allows invoking
another program. This program can be a shell, and on Unix
based machines, it will be a shell---Posix requires that
system() invoke a shell to interpret the command, but you'll
have to see your compiler documentation to find out what it
actually does.
The only real problem is that the shell commands aren't
really portable. Still, Unix look-alikes abound, and there
are a number of Unix-like tool kits for Windows, so if you
use a set of Unix commands (not from the latest Posix
standard, but something a bit older), you can obtain a
limited amount of portability, sufficient for many uses.
I'm not sure if you're joking or are serious... either way
thanks for the bit on system.
Totally serious. I regularly invoke Unix shells via system
under Windows. It does take some playing around with the path
in your environment (the "system" configuration panel, in the
"advanced" section), but it works. The important different I've
seen is that under Unix, system() always invokes the shell to
interpret the command line you've given it; under Windows, it
normally doesn't, but rather interprets it somehow itself (I
think; I've had problems with quoted text in the command line;
things like "someprog -x \"a.*b\"".) If you want full shell
interpretation, you might have to write the command to a file,
and invoke "sh < filename" or "sh filename" in the call to
system().
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=C3=A9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=C3=A9mard, 78210 St.-Cyr-l'=C3=89cole, France, +33 (0)1 30 23 00 =
34