Operating System - HP-UX
1748148 Members
3683 Online
108758 Solutions
New Discussion юеВ

Running telnet commands from a C program

 
SOLVED
Go to solution
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 3
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.