Saturday, May 22, 2010

Linux Command in C programming...?

how to I implement linux command into my C program? I did manage to execute some basic command like "ls","pwd" etc.... however i cant perform command with argument with it like "ls -a -l"... how can i do it without hard coding the command into the program?

Linux Command in C programming...?
"I did manage to execute some basic command like "ls","pwd" etc...."


How? You can run ls, but not ls -a?





You can either do it through system("ls -la") which is defined in stdlib.h, or use execv in unistd.h .
Reply:You just take command line argument,


And Linux provide you a library for parsing command line parameter.


So, you can parse the parameter and do as you want.


No comments:

Post a Comment