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
comands inside the script mercuryshipzz Security 4 02-13-2008 04:25 PM
For Loops Within Ftp Comands jsalz638 UNIX for Advanced & Expert Users 6 10-22-2007 12:20 AM
how to identify the type of shell using comands.. swamymns Shell Programming and Scripting 2 01-18-2006 01:17 AM
External USB otterit SUN Solaris 2 05-02-2005 11:22 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-06-2003
merlin
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
External comands in C?

Hey all,

I'm writting my first C program (Apart from the little ones I did to learn the program).

What I want for this program to do is ping a range of IP's and then place the reply if alive into a file the compare all in that file to the /etc/hosts file to find the host name.

I know I could do it all ina script BUT I want to learn C and do it in that.

The reason I want it to do this is so I can check the main computers on the network can see all the other computers and also to check up if anyone has added any computers onto the network.

I'm pretty sure I can do most of this programming. But how do I call apon a external command? Like I'll need to use 'ping' and compare or something the same.

Also another quickie.

Once I have found the IP 64.1.128.15 (example only) in the 'etc/hosts' file how can I take the WHOLE line and place that into the last file for viewing all this data.

Thanks in advanced for the help.
  #2 (permalink)  
Old 01-07-2003
S.P.Prasad S.P.Prasad is offline
Registered User
  
 

Join Date: Jan 2002
Location: India
Posts: 111
I presume that you may have to work with the following Networking Services Library Functions like:
sethostent ( ) , gethostent ( ) and endhostent ( ) and some Sockets Library Functions like:
ntohs ( ) and inet_ntoa ( ) and
Standard C Library Functions like:
system ( )
There can be multiple ways to solve your requirement and much depends upon how you want to implement it.
See man pages for more explanations.

Last edited by S.P.Prasad; 01-07-2003 at 06:33 AM..
  #3 (permalink)  
Old 01-08-2003
jyotipg jyotipg is offline
Registered User
  
 

Join Date: Oct 2001
Location: Bangalore
Posts: 95
USe System

If you want to execute a Unix command like Ping from a C programe them use the "system" function and execute it.

Check the manual.

man system
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0