Re: Running telnet commands from a C program (187 Views)
Reply
Regular Advisor
Joseph A Benaiah_1
Posts: 79
Registered: ‎11-09-2000
Message 1 of 4 (187 Views)
Accepted Solution

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.
Honored Contributor
Steve Steel
Posts: 2,909
Registered: ‎02-13-2000
Message 2 of 4 (187 Views)

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
Stanimir
Posts: 321
Registered: ‎11-01-2001
Message 3 of 4 (187 Views)

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

Trusted Contributor
Stanimir
Posts: 321
Registered: ‎11-01-2001
Message 4 of 4 (187 Views)

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.


The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.