Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Running telnet commands from a C program

SOLVED
Go to solution
Highlighted
Joseph A Benaiah_1
Regular Advisor

Running telnet commands from a C program

Dear All,

Is it possible to run telnet commands from a C program.

I know that there is a well known piece of freeware called expect that will do this and a module in perl that can also do this, but has anyone done in C and could you provide a small example.

Cheers,

Joseph.
3 REPLIES
Steve Steel
Honored Contributor
Solution

Re: Running telnet commands from a C program

Hi

There are public domain examples

example

http://hpux.cs.utah.edu/hppd/hpux/Networking/WWW/curl-7.9.8/


steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Stanimir
Trusted Contributor

Re: Running telnet commands from a C program

Hi!
It is no difficult. Look at "man" of
functions: execve,execv, execl, execle
Here is simple example of
C-source of executing command "whoami":

function
{ execlp("/usr/bin/whoami","whoami",NULL);
return 0;}

Regards,Stan

Stanimir
Trusted Contributor

Re: Running telnet commands from a C program

And also,
The easiest way to execute a shell-command is to use standard library routine "system".
It takes only 1 argument:

main() {
int stat;
stat = system("date")
/* another rows ...... */
}

Chao,Stan.