FTP判断发送方式

#include <stdio.h>
#include <stdlib.h>
#include "ftp_api.h"
#include "log.h"
#include "public.h"


int pub_dfisftp_sendfile(char *localpath,char *remotepathfile)
{   
vtcp_log(LOG_INOUT,"%s %d ,localpath=[%s],remotepathfile=[%s]\n",__FILE__,__LINE__,localpath,remotepathfile);
char cNodeName[50];
memset(cNodeName,0x00,sizeof(cNodeName));
strcpy(cNodeName,(char *)get_env_info("DFISFTPNODE"));
vtcp_log(LOG_INOUT,"%s,%d ,DFISFTPNODE=[%s]\n",__FILE__,__LINE__,cNodeName);
int ftpfd = ftp_send(cNodeName,localpath, remotepathfile);
if (ftpfd) {
vtcp_log(LOG_INOUT,"%s %d ,发送localpath=[%s],remotepathfile=[%s]失败\n",__FILE__,__LINE__,localpath,remotepathfile);
goto ErrExit;
}
vtcp_log(LOG_INOUT,"%s %d ,发送localpath=[%s],remotepathfile=[%s]成功\n",__FILE__,__LINE__,localpath,remotepathfile);
return 0;
ErrExit:
return -1;
}
/*根据环境变量判断通过什么方式传送文件ADD BY ZHGF 20150414 BEGIN*/
/*功能:使用ftp或iftp传送文件到其他系统
**参数:char *filename 文件名带路径
**返回值:0 成功 -1 失败
**/
int pub_dfisftp_file2out(char *filename)
{
int iRet=0;
if(getenv("FTPFLAG") != NULL && memcmp("iftp",(char *)getenv("FTPFLAG"),4)==0)
{
char cRemotePath[200];
memset(cRemotePath,0x00,sizeof(cRemotePath));
sprintf(cRemotePath,"%s",getenv("CWSEND"));
vtcp_log(LOG_DEBUG,"[%s][%d]要发送的文件名为filename=[%s],远程路径为cRemotePath=[%s]!\n",__FILE__,__LINE__,filename,cRemotePath);
iRet=pub_dfisftp_sendfile(filename, cRemotePath);
if(iRet)
{
vtcp_log(LOG_DEBUG,"[%s][%d]要发送的文件名为filename=[%s],远程路径为cRemotePath=[%s]失败!\n",__FILE__,__LINE__,filename,cRemotePath);
strcpy(g_pub_tx.reply,"G006");
return -1;
}
}
else
{
char cComm[200];
memset(cComm, 0x0, sizeof(cComm));
sprintf(cComm, "ftp2yjj.sh %s",filename);
vtcp_log(LOG_DEBUG,"%s %d cComm=[%s]",__FILE__,__LINE__,cComm);
iRet = system(cComm);
if (iRet != 0)
{
sprintf(acErrMsg, "系统system调用失败!!");
WRITEMSG
strcpy(g_pub_tx.reply,"F999");
return -1;
}
}
return 0;
}
/*根据环境变量判断通过什么方式传送文件ADD BY ZHGF 20150414 END  */
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值