Hi. I have a question about runing system calls within a C program.
I understand that library function "system(string)" takes only
constant strings. Is there an alternative function where I can
use variables as its argument?
Thanks in advance.
Thanks in advance.
I am not sure if I understand you correctly, but this will work:Quote:> Hi. I have a question about runing system calls within a C program.
> I understand that library function "system(string)" takes only
> constant strings. Is there an alternative function where I can
> use variables as its argument?
> Thanks in advance.
.
.
.
strcpy(sys_var,"cat x");
system(sys_var);
.
.
.
system(3) takes any string you want to pass into it, constant or otherwise.
Perhaps what you really mean to say is that system(3) only takes one string,
rather than a list of arguments. If you want to pass in the latter, perhaps
you want to use one of the exec*(2) functions. See the man page for execl(2)
(possibly execl(3)) on your system for more information.
--
Jonathan Kamens USnail:
MIT Project Athena 11 Ashford Terrace
Office: 617-253-8085 Home: 617-782-0710
1. How to execute shell command from within a C program ?
Hi !
Is it possible to execute a shell command (or execute another program)
from within a C program under UNIX ? if it is possible, what is the
C instruction ?
Thank you.
Henri K. Christiaan
.
2. CUPS and DHCP for remote printer
3. Is it possible to excute a single command in a shell script as a different user
4. Max # of files in directory?
5. problem with executing commands from within the shell using a command string.
7. unix shell commands within ftp shell script
8. reading unix program from a diskett
9. Executing a program (shell script) from within a c program
10. How to issue shell commands within FORTRAN?
11. executing a shell command within AWK
12. Invoking SQL commands within K-shell script!
13. How to use a shell built-in command within a sh script ?