Click to See Complete Forum and Search --> : exec() help
I try to execute command: " cat temp* " inside a c prgram
i try exec with: exec("/bin/ls", "-l",0); it works OK but when i try: exec("/bin/cat", "temp*",0); nothing happens...
what can i do?? which system call should i use
CyberCoder
02-26-2004, 03:02 PM
May be try this:
execl("/bin/cat","cat","temp*",0);
the second param must be the name of the command. And "temp*" doesn't mean all files beginning with "temp", it's so only in shell IMHO.
Ok it works that way but i need all files start with temp how can i do this?
CyberCoder
02-26-2004, 03:32 PM
you can use system instead of exec* like this:
system("/bin/cat temp*");
It works :) thanx very much
CyberCoder
02-26-2004, 03:49 PM
Fine :) And don't forget to read man pages :)
snorlaxx
03-03-2004, 08:25 PM
hi guys!
system() works for C codes only, right? what is its counterpart for c++? :) Thanks!
bwkaz
03-04-2004, 08:01 PM
C++ is only a bag on the side of C. Anything that works in C will work in C++ (assuming you use the correct namespace for the functions, i.e. you may have to use ::system(...) instead of system(...) if the class you're calling system() from has a member named system() also).