Computing.Net > Forums > Programming > Calling Unix commands in C?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Calling Unix commands in C?

Reply to Message Icon

Name: too
Date: August 23, 2002 at 07:15:02 Pacific
Comment:

Hellow,
How to exploit basic Unix (linux) commands such as "rm","cd","ls","grep" in C programming? Firstly, I tried bash script but it is not convenient to concern with real number computing. Are there a set of functions in C compiler that behave like "rm","ls","grep"? Where I could get more information?

Thank you,

too



Sponsored Link
Ads by Google

Response Number 1
Name: ravi
Date: August 23, 2002 at 08:11:38 Pacific
Reply:

I guess i wont be able to hundred% of u r problem but try this(since i am not sure whether paramaters are accepted by the system function)
/*Use analog brackets */
#include"iostream.h"
#include"stdio.h"/*optional*/
#include"stdlib.h"
void main()
{
system("ls");
system("cd ..");
system("mkdir hello");
system("rmdir hello")

}
if this gives an error report me back


0

Response Number 2
Name: too
Date: August 23, 2002 at 09:07:31 Pacific
Reply:

Thank you,
Your answer is very helpful. By adding ; to the last statement, the code is workable.But
no "iostream.h" available for both Unix and Linux.


0

Response Number 3
Name: Sajid Mohammed
Date: August 23, 2002 at 13:02:59 Pacific
Reply:

Hi,
What do you mean by iostream.h not available. It is a C++ library and if you use C++ language then you should include that file
Sajid Mohammmed
sajleo@yahoo.com


0

Response Number 4
Name: Ravi
Date: August 23, 2002 at 23:17:44 Pacific
Reply:

My friend iostream doesn.t work because u have installed only the C compiler but not the c++(GCC,C++)compiler ....
To be 100 % sure try working with Classes and objects .Sajid is absolutely right. iF while compiling the code if u get an error(remember to write the syntxs properly)then u r using a C COMPILER and not C
Also try to ind out if there is any file named gcc , c++ in /root , /usr/*(reffers to all dir's especially /bin and /sbib) , /bin ,/sbin,/usr/* etc .....


0

Response Number 5
Name: Ravi
Date: August 23, 2002 at 23:39:03 Pacific
Reply:

Dear Too
Mail me if u want to know smth abt C


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Calling Unix commands in C?

HOW CAN I RUN UNIX COMMANDS in VB6? www.computing.net/answers/programming/how-can-i-run-unix-commands-in-vb6/14264.html

Unix commands in Command prompt? www.computing.net/answers/programming/unix-commands-in-command-prompt/15282.html

DOS commands in C www.computing.net/answers/programming/dos-commands-in-c/9449.html