The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to use UNIX commands in C program sundar.lsr UNIX for Dummies Questions & Answers 3 02-20-2008 04:37 AM
what are some different commands in c shell and korn shell?? EquinoX UNIX for Dummies Questions & Answers 1 01-28-2008 09:14 PM
combining unix commands and awk program Reza Nazarian Shell Programming and Scripting 2 05-19-2006 04:37 PM
How to run unix commands in a new shell inside a shell script? hkapil Shell Programming and Scripting 2 01-04-2006 03:56 AM
KORN Shell - Spawn new shell with commands frustrated1 Shell Programming and Scripting 2 04-20-2005 11:23 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-14-2005
esham's Avatar
Registered User
 

Join Date: Nov 2004
Location: INDIA
Posts: 97
shell commands in c program

Hi All,

I want to include some shell commands in my c program in linux.
please help..

thanks in advance
esham
Reply With Quote
Forum Sponsor
  #2  
Old 10-14-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
Go through the man pages of popen and pclose. These allow you to execute commands and read/write from/to them.
Reply With Quote
  #3  
Old 10-15-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
Also look at the man page for system(). It lets you run a command easily, but you can't do i/o to or from the command.
Reply With Quote
  #4  
Old 10-15-2005
krhamidou's Avatar
Registered User
 

Join Date: Oct 2005
Posts: 27
you could also see the manual page of exevp .

Last edited by krhamidou; 10-16-2005 at 04:27 AM.
Reply With Quote
  #5  
Old 10-18-2005
esham's Avatar
Registered User
 

Join Date: Nov 2004
Location: INDIA
Posts: 97
system() functions work fine.

But iam not able to give input for any commands

for eg:

can i give

var=/home/esham
ret=system("ls $var");

Please help..
Reply With Quote
  #6  
Old 10-19-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
Esham,

You cannot assign "var=/home/esham" in C, you are talking about shell scripting. In C you would have variables like
Code:
char var[]="/home/esham";
It would help if you tell what exactly you want to do and how you are trying to do it.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0