which function do i use to give such linux terminal calls in my c program?
+8
A:
system
would be the correct posix call. It takes a pointer to char as the command to be executed. See man 3 system
. However system
can be completely corrupted by environment variables and an harder-to-use alternative is exec
(see here).
A little example to illustrate:
system("xeyes");
system("rm -rf $HOME"); /* never ever try this, really */
pmr
2010-07-13 20:53:55
Have you included the quotes? ie system("xeyes"), NOT system(xeyes)
Noel M
2010-07-13 21:03:42
@Noel I don't think he has. Thus my examples and clarification.
pmr
2010-07-13 21:05:54
+1 for newbie humility :-)
JBRWilkinson
2010-07-13 22:15:05