- 论坛徽章:
- 0
|
shell 如下:
echo "\033[3;10H远程主机名[或IP]:\c"
read host
if [ "$host" = "" ];then
exit
fi
echo "\033[4;10H远程机用户名:\c"
read user
echo "\033[5;10H远地用户口令:\c"
echo "\033[2;8;8m\c"
read password
因为想得到telnet上来的机器ip,然后通过shell 自动ftp回去,写大个程序得到客户端ip,不知道
该如何把c语言中得到的ip付给shell中,有谁知道吗
#include <sys/types.h>;
#include <utmpx.h>;
#include <pwd.h>;
#include <stdio.h>;
//char * getclientaddr(void)
main()
{
static char ClientAddr[255],getaddr[35];
struct utmpx * entry=NULL;
char * mytty;
mytty=ttyname(0)+(unsigned char *)strlen("/dev/");
setutxent();
while(entry=getutxent())
{
strcpy(getaddr,entry->ut_line);
if(!strcmp(entry->ut_line,mytty))
{
strcpy(ClientAddr,entry->ut_host);
break;
}
}
endutxent();
printf("%s\n",ClientAddr);
return ClientAddr;
} |
|