Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

Running telnet commands from a C program

SOLVED
Go to Solution
Regular Advisor 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
Honored Contributor Honored Contributor

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)
Trusted Contributor 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

Highlighted
Trusted Contributor 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.