关于tftp错误信息的问题
fpsh = fopen("/bin/tftpshell","w");
if(fpsh != NULL)
{
fprintf(fpsh,"#!/bin/sh\n");
fprintf(fpsh,"tftp %s\n", dot_dec_ip_addr);
fclose(fpsh);
}
else
{
PRINT_INFO("open new file error \n");
return 1;
}
chmod("/bin/tftpshell", S_IRWXU|S_IRWXG);
fp=popen("./tftpshell","w");
if(fp!=NULL)
{
fprintf(fp,"bin\n");
fprintf(fp,"get %s\n", fil_nam);
fprintf(fp,"quit\n");
pclose(fp);
}
else
{
PRINT_INFO("popen tftp error \n");
return 1;
}
这段代码是利用脚本和popen管道实现登陆tftp服务器并且下载文件的小程序,dot_dec_ip_addr是从外部传入的tftp服务器ip地址,fil_nam是从外部传入的要下载的文件名,正常情况下是完全没问题的,但是如果tftp服务器没开,或者服务器上没有我要下载的这个文件,这样的出错信息应该到什么地方找呢?只要ip地址正确,就始终不可能进入popen的出错程序中,就是最后的这个else段中。各位大虾帮帮忙吧,很急的,谢谢了
|