03-16-2009
calling a c executable inside c program
hello please see the code snippet:-
#include<unistd.h>
int main()
{
const char* command ="./freenull";
execvp(command,NULL);
return 0;
}
/* in the same programme if u want u can create a child and can do the same inside that*/
or
#include<unistd.h>
int main()
{
const char* command="./freenull";
system("command");
return 1;
}
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
here's the Perl code snippet...
how can i call my C executable 'porter-stemmer' and pass it $1 as
an argument? Thanks for the help!
# Read through the original topic set, and modify based on the current
# pre-processing options
while (<TOPIC_ORIG>)
{
# Run pre-processing over only the... (3 Replies)
Discussion started by: mark_nsx
3 Replies
2. Programming
Hi,
I want to write a program in C or in Perl which will tell me that a function is called in which executables.
I tried to use the unix command like 'nm', 'strings' and so on to find out whether a function is called in that executable or not but could not able to find a clue. The whole... (1 Reply)
Discussion started by: rocky_74
1 Replies
3. Programming
Hi everybody!
Could you please tell me how can I launch an executable from a C++ (on unix) program?
thanks in advance! (2 Replies)
Discussion started by: nadiamihu
2 Replies
4. Shell Programming and Scripting
Hi all ,
I need to call an executable (.exe) using shell script.
Actual need is i need to call that shell script and do an export of some tables
is there any way . the executable is datamover
Please let me know if there are any option !! (2 Replies)
Discussion started by: raghav1982
2 Replies
5. Shell Programming and Scripting
Now I am using the HP-UX11.11 version.
The scripts are runninh in KSH shell.
While I wan to call one executable of any Pro*C file, I have got the following error, however the executable is running fine directly.
testpri Started at 10.05.200923:40
/usr/lib/dld.sl: Bad magic number for... (0 Replies)
Discussion started by: priyankak
0 Replies
6. Shell Programming and Scripting
Dear list
its my first post and i would like to greet everyone
What i would like to do is select records 7 and 11 from each files in a folder then run an executable inside the script for the selected parameters.
The file format is something like this
7 100 200
7 100 250
7 100 300 ... (1 Reply)
Discussion started by: Gtolis
1 Replies
7. Programming
hi guys
i have only basic knowledge of C so guys plz help me .....
is C language support call the C executable inside the C ??
example contect mainA.c have a many function define in the struct,when i compile mainA and make a executable the name is ( A ),can i use executable C inside the C... (5 Replies)
Discussion started by: isnoname
5 Replies
8. Programming
Can anyone give me a makefile that creates 3 exe?for example, let's suppose i have the following files:
blah1.c
blah1.h
blah2.c
blah2.h
blah3.c
blah3.h
i've searched and searched but so far i was not able to complete it. (4 Replies)
Discussion started by: bashuser2
4 Replies
9. Shell Programming and Scripting
Hi, I am making a program that needs to detect if the program name in parameter is a valid runable program.
But the line if ; then never seem to work.
Even if I run like:
./script cat "-u" cat "-u" inputfile
Thank you everyone.
#!/bin/bash
#
usage() { #print usage message and quit... (4 Replies)
Discussion started by: leonmerc
4 Replies
10. Shell Programming and Scripting
I am running the below loop that to process the 3 bam files (which isn't always the case). A .py executable is then called using | xargs sh to further process. If I just run it with echo the output is fine and expected, however when
| xargs sh is added I get the error. I tried adding | xargs... (4 Replies)
Discussion started by: cmccabe
4 Replies
LEARN ABOUT DEBIAN
stcallcmderrno
stcall(3) ShapeTools Toolkit Library stcall(3)
NAME
stCallEditor, stCallCmd, stCallCmdErrno, stFindProgram - call command processor with command string
SYNOPSIS
#include <config.h>
#include <sttk.h.h>
int stCallEditor (char *editor, char *file, char *contents, char **newcontents);
int stCallCmd (char *commandProcessor, char *commandString);
int stCallCmdErrno;
char*stFindProgram (char *fileName)
DESCRIPTION
stCallEditor calls editor editor with file file and returns its contents after the editor session in newcontents. Return value is the
length of the new text. On failure, 0 is returned to indicate the error. Newcontents is not updated and points to nowhere. On error the
file will be removed. If contents points to a valid text, this text is put (not appended) into the temporary file before editor starts.
Contents must be NULL terminated, otherwise strange things will happen.
stCallCmd invokes commandProcessor as a child process and writes commandString to its standard input. The current process waits for termi-
nation of the child process. stCallCmd returns the exit status of the child process reported by wait(2). The commandProcessor string may
contain command line arguments to the command processor, separated by whitespace. (This is necessary for some programs to make them read
commands from standard input.) The command processor program is searched for in the directories given in the environment variable PATH.
If commandString does not end with a newline, a newline is added.
stFindProgram returns the full pathname of programName if program is found and executable. Otherwise NULL.
ENVIRONMENT
PATH List of colon-separated directoriy names where execvp(3) searches for the program to execute (default /bin:/usr/bin:/usr/ucb).
SEE ALSO
wait(2)
DIAGNOSTICS
On a successful call stCallCmd returns the exit status of the child process. If an error occured, stCallCmd returns a negative number as
defined in sttk.h:
CMDPROC_EMPTY
An empty or NULL string has been supplied for commandProcessor.
NO_MORE_CORE A call to malloc(3) or calloc(3) returned a NULL pointer.
FORK_FAILED fork(2) could not create a child process.
PIPE_FAILED A call to pipe(2) failed.
WAIT_ERROR A call to wait(2) failed.
EXEC_FAILED execvp(3) could not execute commandProcessor.
CHILD_KILLED The child process was killed by an uncaught signal.
WRITE_FAILED write(2) could not write commandString to the pipe. This usually happens when commandProcessor does not read its standard
input and terminates before commandString is written.
NO_PROGRAM commandProcessor could not be found.
For the most error conditions the integer variable stCallCmdErrno (declared in sttk.h) contains additional information about the error con-
dition, usually the contents of errno(3) after a failed system call.
In the case of CHILD_KILLED, stCallCmdErrno contains the statBus of the child process as reported by wait(2).
BUGS
On systems where no usable vfork(2) is available, the value of stCallCmdErrno does not make sense in case of EXEC_FAILED.
Under IRIX stCallCmd sometimes (or always?) returns WAIT_ERROR where it should be EXEC_FAILED, NO_PROGRAM, or WRITE_FAILED.
AUTHORS
Jurgen Nickelsen <nickel@cs.tu-berlin.de> and Andreas.Lampen@cs.tu-berlin.de
sttk-1.7 Thu Jun 24 17:43:29 1993 stcall(3)