LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-15-2004, 08:40 AM   #1
dennyvm
LQ Newbie
 
Registered: Jan 2004
Location: India
Distribution: redhat
Posts: 2

Rep: Reputation: 0
Question Executing Linux commands in C programs--->please help


Hai--I'm new to Linux programming but I'm familiar with most of the administrative part of Linux..I would like to know about using Linux commands in a C program, and also about how to create a time stamped file and write to it...

Could anyone guide me or tell me about resources which deals with the above in a detailed manner?

Thank you..This is my first post

-->dennyvm
 
Old 01-15-2004, 09:14 AM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
The command you are looking for is exec. It comes in a variety of forms. Type "man 3 exec" at the command line to read about it. As far as writing files goes, you will want to look into fopen and fprintf. fopen will create a file if you attempt to open a file that doesn't exist already. All files you create should be timestamped to the last time they were written to.
 
Old 01-15-2004, 09:51 AM   #3
luxitan
Member
 
Registered: Aug 2003
Location: Portugal
Distribution: Gentoo
Posts: 78

Rep: Reputation: 15
you should check the system command too
 
Old 01-15-2004, 10:51 AM   #4
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
ya, luxitan is right.

System executes a system call and waits for it to complete before moving on. Exec executes a system call and complete replaces the current running process with the new call. If you don't need to wait for the call to finish you can fork and then exec, otherwise using the system call is what you would want to do.

John
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux programs(commands) path sureshkellemane Linux - Newbie 6 03-29-2005 02:15 AM
executing shell commands in c++ true_atlantis Programming 2 10-01-2004 04:53 PM
Executing commands in Konsole... meteotrade Linux - General 5 10-20-2003 06:34 PM
python, executing regular linux commands Robert0380 Programming 3 06-26-2003 03:35 PM
Executing commands on startup viciousfish Linux - General 5 06-28-2002 02:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration