Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoking Linux/unix uitility programs within C++ 1

Status
Not open for further replies.

pipk

Programmer
Feb 20, 2001
455
GB
hello everyone

my problem is that i am fairly new to C++ and need to invoke a linux program from within my C++ code. I am writing an image processing program that converts full colour .ppm files to grey-scale .pgm files and would like my program to automatically invoke a utility such as XV or gimp. any clues??

 
look into the system() or exec() calls, using

man system
and man exec

These will give you more info...

Good Luck!

From man system->

YSTEM(3) Linux Programmer's Manual SYSTEM(3)

NAME
system - execute a shell command

SYNOPSIS
#include <stdlib.h>

int system (const char * string);

DESCRIPTION
system() executes a command specified in string by calling
/bin/sh -c string, and returns after the command has been
completed. During execution of the command, SIGCHLD will
be blocked, and SIGINT and SIGQUIT will be ignored.

RETURN VALUE
The value returned is 127 if the execve() call for /bin/sh
fails, -1 if there was another error and the return code
of the command otherwise.

If the value of string is NULL, system() returns nonzero
As always, I hope that helped!

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top